高手请进__急--关于回调函数的问题
//枚举所有的窗口,然后向窗口发送关闭的消息
#include <windows.h>
BOOL CALLBACK EnumWindowsProc( HWND hwnd,
DWORD lParam
);
//
// EnumWindowsProc must be called from a Windows
// application on Windows 95.
//
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
//
// Close all open applications.
//
// HWND oldHWnd = NULL;
EnumWindows(EnumWindowsProc, 0);
// Now do a regular logoff.
ExitWindowsEx(EWX_LOGOFF , 0);
return 1;
}
BOOL static CALLBACK EnumWindowsProc(
HWND hwnd,
DWORD lParam
)
{
DWORD pid = 0;
LRESULT lResult;
HANDLE hProcess;
DWORD dwResult;
lResult = SendMessageTimeout(
hwnd,
WM_QUERYENDSESSION,
0,
ENDSESSION_LOGOFF,
SMTO_ABORTIFHUNG,
2000,
&dwResult);
if( lResult )
{
//
// Application will terminate nicely, so let it.
//
lResult = SendMessageTimeout(
hwnd,
WM_ENDSESSION,
TRUE,
ENDSESSION_LOGOFF,
SMTO_ABORTIFHUNG,
2000,
&dwResult);
}
else // You have to take more forceful measures.
{
//
// Get the ProcessId for this window.
//
GetWindowThreadProcessId( hwnd, &pid );
//
// Open the process with all access.
//
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
//
// Terminate the process.
//
TerminateProcess(hProcess, 0);
}
//
// Continue the enumeration.
//
return TRUE;
}
出错,如下
--------------------Configuration: EnumWindows - Win32 Debug--------------------
Error: Could not delete file "G:\新s2012\邹军\VC++\资料\如何枚举窗口句柄\EnumWindows\Debug\EnumWindows.obj" : 找不到网络路径。
EnumWindows.obj - 1 error(s), 0 warning(s)
请高手指点一下,在下不胜感激