Problem: innerhalb der Komponente wird eine Prozedur erwartet die aufgerufen wird, wenn ein (bereits laufendes - also erste Instanz) Programm erkennt, dass jemand versucht hat, noch eine Kopie zu starten. Es geht jetzt nicht um das was mach ich dann, sondern darum, wie ich meine eigene Prozedur zuweisen muss, dich ich bisher einfach als Property in der IDE eingetragen habe. Das ist die Komponente ...
Code: Alles auswählen
type
TOnOtherInstance = procedure (Sender : TObject; ParamCount: Integer; const Parameters: array of String) of object;
{ TUniqueInstance }
TUniqueInstance = class(TComponent)
private
FIdentifier: String;
FOnOtherInstance: TOnOtherInstance;
FUpdateInterval: Cardinal;
FEnabled: Boolean;
FPriorInstanceRunning: Boolean;
procedure ReceiveMessage(Sender: TObject);
{$ifdef PollIPCMessage}
procedure CheckMessage(Sender: TObject);
{$endif}
protected
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
property PriorInstanceRunning: Boolean read FPriorInstanceRunning;
published
property Enabled: Boolean read FEnabled write FEnabled default False;
property Identifier: String read FIdentifier write FIdentifier;
property UpdateInterval: Cardinal read FUpdateInterval write FUpdateInterval default 1000;
property OnOtherInstance: TOnOtherInstance read FOnOtherInstance write FOnOtherInstance;
end;
Code: Alles auswählen
procedure MyUniqueInstanceOtherInstance(Sender: TObject; ParamCount: integer; Parameters: array of string);
// what to do if a second instance is detected
begin
...
end;
Code: Alles auswählen
MyUniqueInstance := TUniqueInstance.Create(Application);
MyUniqueInstance.OnOtherInstance := @MyUniqueInstanceOtherInstance;
Code: Alles auswählen
Error: Incompatible types: got "<address of procedure(TObject;LongInt;{Open} Array Of AnsiString);Register>" expected "<procedure variable type of procedure(TObject;LongInt;const {Open} Array Of AnsiString) of object;Register>"
Thnx, Armin