Results 1 to 3 of 3

Thread: EnumWindows

  1. #1

    Thread Starter
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153

    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?
    Last edited by Cbomb; Aug 6th, 2001 at 08:43 AM.
    Cbomb
    Techie

  2. #2

    Thread Starter
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153
    bump
    Cbomb
    Techie

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You should remove the asterisk before the EnumWindowProc
    Code:
    EnumWindows(EnumWindowProc, 0);  // no asterisk here!!
    That should do it.

    All the buzzt
    CornedBee

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width