关机,重起,注销:用ExitWindowEx 如果要关闭Exploer, Please use 'Findwindow', then 'SendMessage' or 'PostMessage'; Please make sure that you find right window Handl.GetDestopWindow will return the first window that win98 start. and it is the parent window of all other windows. I hope that will help you.
::SendMessage(hwnd,WM_COMMAND,SC_CLOSE,0); or ::PostMessage(hwnd,WM_COMMAND,SC_CLOSE,0);注:发的消息相当于选“退出”,或点叉,发WM_CLOSE不成,嘿嘿,我试过,音箱“咚咚”,就是不退,更狠的,WM_QUERYENDSESSION
要用到以下几个API函数: BOOL EnumWindows( WNDENUMPROC lpEnumFunc, // pointer to callback function LPARAM lParam // application-defined value ); 枚举窗口列表中的所有父窗口(顶级和被所有窗口) BOOL PostMessage( HWND hWnd, // handle of destination window UINT Msg, // message to post WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ); 将一条消息投递到指定窗口的消息队列 int GetWindowText( HWND hWnd, // handle to window or control with text LPTSTR lpString, // address of buffer for text int nMaxCount // maximum number of characters to copy ); 取得一个窗体的标题(caption)文字
如果要关闭Exploer,
Please use 'Findwindow', then 'SendMessage' or 'PostMessage';
Please make sure that you find right window Handl.GetDestopWindow will return the first window that win98 start. and it is
the parent window of all other windows.
I hope that will help you.
ASSERT(pWnd);
pWnd->PostMessage(WM_CLOSE);
可以做到。但这样作依赖窗口的标题必须是"我的电脑"
如果我们进入了一个目录,窗口标题一变就不行了。
至于为何,不知道谁可以说个明白?
人家要关闭又来问你同意不,你说等会,你关闭先,然后我回答你
PostMessage是把消息发送到消息队列中的
or ::PostMessage(hwnd,WM_COMMAND,SC_CLOSE,0);注:发的消息相当于选“退出”,或点叉,发WM_CLOSE不成,嘿嘿,我试过,音箱“咚咚”,就是不退,更狠的,WM_QUERYENDSESSION
先找到当前运行程序的窗口pWnd,再遍历系统所有窗口,看有没有窗口的TITLE =“我的电脑”
有则pWnd->postmessage(WM_CLOSE)
BOOL EnumWindows(
WNDENUMPROC lpEnumFunc, // pointer to callback function
LPARAM lParam // application-defined value
);
枚举窗口列表中的所有父窗口(顶级和被所有窗口) BOOL PostMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to post
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
将一条消息投递到指定窗口的消息队列 int GetWindowText(
HWND hWnd, // handle to window or control with text
LPTSTR lpString, // address of buffer for text
int nMaxCount // maximum number of characters to copy
);
取得一个窗体的标题(caption)文字