Click to See Complete Forum and Search --> : How to pass the address of a function in a DLL(Built with VC++) to API function?


Walter Lee
May 2nd, 2001, 01:30 AM
Hi,
I'm trying to control a dialog window created by another process in VB, so I think I need a global hook. I write a C DLL with a Callback function in it and declared it in an module in my VB project. and I want to pass this function to the Windows API SetWindowsHookEx. But error occurs when I use the Addressof operator.
The definition of the callback function in the dll is like this:
LRESULT WINAPI __stdcall MessageProc(int nCode, WPARAM wParam, LPARAM lParam);
and I declare it in VB like this:
public Declare Function MessageProc Lib "MyDll.dll" (byval nCode as integer, byval wParam as long, byval lParam as long) as long

What's the problem?
Thx.