|
-
December 12th, 2008, 03:13 PM
#1
Cant make EnumWindowsProc work
Hello,
I have the following problem:
I need to get a list of all active windows. For that, I'm trying to use EnumWindows function and that means that I overwrite EnumWindowsProc.
This functions shoul look like this (taken from msdn.microsoft.com):
Code:
BOOL EnumWindows(WNDENUMPROC lpEnumFunc, LPARAM lParam);
Parameters:
lpEnumFunc
[in] Pointer to an application-defined callback function. For more information, see EnumWindowsProc.
lParam
[in] Specifies an application-defined value to be passed to the callback function.
Code:
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
Parameters:
hwnd
[in] Handle to a top-level window.
lParam
[in] Specifies the application-defined value given in EnumWindows or EnumDesktopWindows.
I wrote a small test .dll:
Code:
#include <windows.h>
#include <vcl.h>
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) {
return TRUE;
}
int APIENTRY DllMain (HINSTANCE hInstance,
DWORD ulReason,
LPVOID lpReserved)
{
EnumWindows(EnumWindowsProc, NULL);
return 1;
}
But whenever i try to compile it, i get the following message:
[C++ Error] Unit1.cpp(60): E2342 Type mismatch in parameter 'lpEnumFunc' (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,long)')
If I remove parameters from EnumWindowsProc it will work, but then I dont know why would I need it to =)
I'd be really grateful for any idea why is that happening.
Thanks.
-
December 12th, 2008, 09:20 PM
#2
Re: Cant make EnumWindowsProc work
Try it like so...
Code:
EnumWindows((WNDENUMPROC)EnumWindowsProc,0);
-
December 13th, 2008, 03:41 AM
#3
Re: Cant make EnumWindowsProc work
 Originally Posted by bitshifter420
Try it like so...
Code:
EnumWindows((WNDENUMPROC)EnumWindowsProc,0);
Yup. Cant believe it was that easy =)
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|