I already posted this message on the gamedev.net forums, but I'm gonna try my luck here too.

I downloaded the Clootie's DirectX 9 header conversions and wanted to try out the DirectPlay stuff, but I ran into problems with my message handling callback routine.

Here's my callback routine:
Code:
function TDirectPlayServer.DPMessageHandler(pvUserContext: Pointer; dwMessageType: DWORD; pMessage: Pointer): HRESULT; stdcall;
begin
	Result := S_OK;
end;
I try to use it like this (like I've done with the Windows API callbacks before):
Code:
...
hr := DPServer.Initialize(NIL, @DPMessageHandler, 0);
...
The problems is that my code won't compile, the error message that I get is "Variable required".

The initialize function is declared like this:
Code:
function Initialize(pvUserContext: Pointer; pfn: TFNDPNMessageHandler; dwFlags: DWORD): HResult; stdcall;
And the callback is declared like this:
Code:
TFNDPNMessageHandler = function (pvUserContext: Pointer; dwMessageType: DWORD; pMessage: Pointer): HRESULT; stdcall;
  {$NODEFINE TFNDPNMessageHandler}
  {$HPPEMIT 'typedef PFNDPNMESSAGEHANDLER TFNDPNMessageHandler;'}
I can easily set the handler if I declare it outside the class like this:
Code:
function DirectPlayMessageHandler(pvUserContext: Pointer; dwMessageType: DWORD; pMessage: Pointer): HRESULT; stdcall;
begin
	Result := S_OK;
end;
But it's kinda useless, because I can't access the private methods/variables on my server class.

The solution is simple, but I just can't grasp it right now.

Any help greatly appreciated.