我在程序中使用
EnumDesktopWindows(hdesk, (WNDENUMPROC)KillScreenSaverFunc, 0);编译时报错:'type cast':cannot convert from " to 'int(__stdcall*)(struct HWND __*,long)'

解决方案 »

  1.   

    肯定KillScreenSaverFunc的定义有问题,给你一个例子#include "stdafx.h"
    #include <stdio.h>
    #include <windows.h>BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
    {
    char szCaption[256]; if (IsWindowVisible(hwnd))
    {
    GetWindowText(hwnd, szCaption, 256); printf("%s.\n", szCaption);
    } return TRUE;
    }int main(int argc, char* argv[])
    {
    DWORD dwThreadId; 
        HWINSTA hwinstaSave; 
        HDESK hdeskSave;     hwinstaSave = GetProcessWindowStation(); 
        dwThreadId  = GetCurrentThreadId(); 
        hdeskSave   = GetThreadDesktop(dwThreadId); 

    EnumDesktopWindows(hdeskSave, EnumWindowsProc, NULL); return 0;
    }