WIN32 API编程--调用关闭计算机对话框

此功能是通过shell32.dll中一个索引号为60的API函数调用,显示"关闭Windows"对话窗口实现的。具体方法为IDC_SHUTDOWNCOMPUTER按钮添加BN_CLICKED消息处理函数:
void CControlDlg::OnShutdowncomputer()
{
    HINSTANCE hInst=LoadLibrary("shell32.dll");//装入shell32.dll
    SHUTDOWNDLG ShutDownDialog;//指向shell32库中显示关机对话框函数的指针
    if(hInst!=NULL)
    {
        //获得函数的地址并调用之
        ShutDownDialog=(SHUTDOWNDLG)GetProcAddress(hInst,(LPSTR)60);//
  (*ShutDownDialog)(0);
    }
}
函数中的SHUTDOWNDLG定义如下:
typedef int (CALLBACK *SHUTDOWNDLG)(int);//显示关机对话框函数的指针

posted @ 2006-03-14 02:15  Max Woods  阅读(821)  评论(0编辑  收藏  举报