来自www.Move2008.com
//Hard Reset!
#include <winioctl.h>
#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
extern "C" __declspec(dllimport)void SetCleanRebootFlag(void);
extern "C" __declspec(dllimport) BOOL KernelIoControl( DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize, LPVOID lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned);
BOOL HardResetPocketPC() { SetCleanRebootFlag(); return KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL); }
////////////////////////////////////////////////////
//全屏 void FullScreen(HWND hDlg) { RECT rc; GetWindowRect(hDlg, &rc); SHFullScreen(hDlg, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON); MoveWindow( hDlg, rc.left, rc.top, rc.right, rc.bottom, TRUE); }
//类似参数要注意SHFS_HIDETASKBAR HIDE为隐藏、SHOW为显示
////////////////////////////////////////////////////
//WinSDK编程 显示隐藏光标
int nWaitCursorCount; //光标记数器
/****************************************************** *显示隐藏光标nCode=1为显示,-1为隐藏 *****************************************************/ void SHCursor(int nCode) { static HCURSOR cur; static BOOL bo=true; if (bo) { cur = ::LoadCursor(NULL, IDC_WAIT); bo = false; } m_nWaitCursorCount += nCode; if (m_nWaitCursorCount > 0) { HCURSOR hcurPrev = ::SetCursor(cur); if (nCode > 0 && m_nWaitCursorCount == 1) m_hcurWaitCursorRestore = hcurPrev; } else { // turn everything off m_nWaitCursorCount = 0; // prevent underflow ::SetCursor(m_hcurWaitCursorRestore); } }
/****************************************************** *开始显示光标 *****************************************************/ void BeginCursor() { m_nWaitCursorCount = 0; SHCursor(1); }
/****************************************************** *结束显示光标 *****************************************************/ void EndCursor() { m_nWaitCursorCount = 0; SHCursor(-1); }
//////////////////////////////////////////////////////////
//调用其它程序
/****************************************************** *打开其它应用程序 *****************************************************/ void Shell(HWND hWnd,LPTSTR ProPath) { int ret; LPTSTR exec = (LPTSTR)malloc(MAX_PATH); SHELLEXECUTEINFO shi; exec = ProPath; shi.cbSize = sizeof(SHELLEXECUTEINFO); shi.lpVerb = TEXT("open"); shi.lpFile = exec; shi.nShow = SW_SHOWNORMAL; ret = ShellExecuteEx(&shi); }
////////////////////////////////////////////////////////
//WINSDK 弹出式菜单
/****************************************************** *弹出菜单 *****************************************************/ VOID APIENTRY PopupMenu ( HWND hWnd, POINT point, int IDM) { HMENU hMenu; HMENU hMenuTrackPopup; // 得到弹出菜单资源 hMenu = LoadMenu (ghInst, MAKEINTRESOURCE(IDM)); if (!hMenu) return;
hMenuTrackPopup = GetSubMenu (hMenu, 0); ClientToScreen (hWnd, (LPPOINT)&point); TrackPopupMenu (hMenuTrackPopup, 0, point.x, point.y, 0, hWnd, NULL); DestroyMenu (hMenu); } 
|