-
EnumWindows
This code produces this error where I have commented
ERROR:
error C2664: 'EnumWindows' : cannot convert parameter 1 from 'int (void *,long)' to 'int (__stdcall *)(void)'
CODE:
Code:
#include <windows.h>
#include <stdio.h>
#include <string>
using namespace std;
BOOL CALLBACK EnumWindowsProc(HWND thehwnd, LPARAM lParam);
string fullmessage;
string windowlist;
int winnum;
int main()
{
char pcUserName[100];
char pcCompName[100];
unsigned long lLength = 100;
GetUserName(pcUserName, &lLength);
GetComputerName(pcCompName, &lLength);
printf("<USER>%s|<COMP>%s\n", pcUserName, pcCompName);
winnum = 0;
windowlist = "";
EnumWindows(*EnumWindowsProc, 0); //ERROR here
return 0;
}
BOOL CALLBACK EnumWindowsProc(HWND thehwnd, LPARAM lParam)
{
int slength;
char buffer[100];
char titletext[100];
char windownumlabel[20];
int retVal;
slength = GetWindowTextLength(thehwnd);
if (slength > 1)
{
if (IsWindowVisible(thehwnd) != 0)
{
winnum++;
retVal = GetWindowText(thehwnd, buffer, slength);
windowlist.insert(windowlist.length(), buffer);
windowlist.insert(windowlist.length(), "\n");
}
}
return 1;
}
Does anyone know how to fix this?
-
-
You should remove the asterisk before the EnumWindowProc
Code:
EnumWindows(EnumWindowProc, 0); // no asterisk here!!
That should do it.
All the buzzt
CornedBee