快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

和记娱乐备用:VC程序实现关闭和重起计算机



因为实际必要做一个VC法度榜样实现关闭和重起谋略机的小器械,刚刚做完,发出来给大年夜家一路钻研下.

//Mfc编写activex控件时取得控件容器句柄

//假如是取容器接口指针

LPOLECONTAINER lpContainer;

HRESULT hr = m_pClientSite->GetContainer(&lpContainer);

关闭谋略机

OSVERSIONINFO OsVersionInfo; //包孕操作系统版本信息的数据布局

OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

GetVersionEx(&OsVersionInfo); 和记娱乐备用//获取操作系统版本信息

if(OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)

{

//Windows98,调用ExitWindowsEx()函数从新启动谋略机

DWORD dwReserved;

ExitWindow和记娱乐备用sEx(EWX_REBOOT,dwReserved); //可以改变第一个参数,实现注销用户、

//关机、关闭电源等操作

// 退出前的一些处置惩罚法度榜样

}

重启谋略机

typedef int (CALLBACK *SHUTDOWNDLG)(int); //显示关机对话框函数的指针

HINSTANCE hInst = LoadLi和记娱乐备用brary("shell32.dll"); //装入shell32.dll

SHUTDOWNDLG ShutDownDialog; //指向shell32.dll库中显示关机对话框函数的指针

if(hInst != NULL)

{

//得到函数的地址并调用之

ShutDownDialog = (SHUTDOWNDLG)GetProcAddress(hInst,(LPS和记娱乐备用TR)和记娱乐备用60);

(*ShutDownDialog)(0);

}

//假如是取窗口句柄

HWND m_hWndParent;

IOleInPlaceSite *pOleInPlaceSite = NULL;

if (NOERROR==m_pClientSite->QueryInterface(IID_IOleInPlaceSite, (LPVOID *)&pOleInPlaceSite))

{

pOleInPlaceSite->GetWindow((HWND *)&m_hWndParent);

pOleInPlaceSite->Release();

}

您可能还会对下面的文章感兴趣: