Habe das jetzt so gelöst, da ich eh schon einen Handler für WmCopyData im Programm habe.
ExeB
Delphi-Quellcode:
var
hExistingInstance: THandle;
pName: PChar;
aCopyData: TCopyDataStruct;
procedure SendRecord(const aRecordToSend: TCopyDataStruct);
begin
aCopyData.dwData := ... irgendein int wert, max cardinal;
SendMessage(hExistingInstance, WM_COPYDATA, 0, LPARAM(@aCopyData));
end;
procedure SendReturnCode(const ReturnString: string);
begin
pName := PChar(ReturnString);
aCopyData.cbData := (StrLen(pName) + 1) * SizeOf(PWideChar);
aCopyData.lpData := pName;
SendRecord(aCopyData);
end;
hExistingInstance := FindWindow(PChar('TFormBlubb'), nil);
if (hExistingInstance = 0) then
SendReturnCode('NixOK')
else
SendReturnCode('AllesOK');
ExeA
Delphi-Quellcode:
private
{Private-Deklarationen}
procedure WMCopyData(var msg: TWMCopyData); message WM_COPYDATA;
procedure TFormBlubb.WMCopyData(var msg: TWMCopyData);
begin
if msg.CopyDataStruct.dwData = TProgramMeta.iUniqueMutexID then
Blubb(msg, TParameterType.ptNull)
else
inherited;
end;
procedure Blubb(const ParameterList: string; const aParameterType: TParameterType);
begin
showmessage(ParameterList);
end;