program Test;
uses Windows;
var
ServiceWnd: HWND;
ServiceWndClass: Windows.TWndClass;
{ Queue message handling }
function ServiceWndProc(HWindow: HWnd; Message: UINT; WParam: WPARAM; LParam: LPARAM): Longint;stdcall;
begin
Result:=0;
{ Client response }
if (Message=MyMessage) then
begin
Writeln('Got Message');
Result := 1;
end else
{ Default }
Result:=DefWindowProc(HWindow,Message,WParam,LParam);
end;
begin
ServiceWndClass.lpfnWndProc := @ServiceWndProc;
ServiceWndClass.hInstance := HInstance;
ServiceWndClass.lpszClassName := 'DemoClass';
ServiceWnd := CreateWindowEx(WS_EX_TOOLWINDOW, PChar('DemoClass'),
'Demo', WS_POPUP {!0}, 0, 0, 0, 0, 0, 0, HInstance, nil);
if (ServiceWnd=0) then
Exit;
while True do
Sleep(10);
DestroyWindow(ServiceWnd);
end;