标签:api hand com app pts word timer init hello
unsigned APIENTRY ThreadProc(void *p)
{
WaitForSingleObject(g_hWaitableTimer, INFINITE);
MessageBox(NULL, _T("线程开始启动"), _T("HELLO"), MB_OK);
return 0;
}
void APIENTRY ApcCompletionRoutine(PVOID pParm, DWORD dwTimerLowValue, DWORD dwTimeHighValue)
{
MessageBox(NULL, _T("ApcCompletionRoutine开始启动"), _T("HELLO"), MB_OK);
return;
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: 在此放置代码。
unsigned ThreadId;
HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, ThreadProc, NULL, NULL, &ThreadId);
g_hWaitableTimer = CreateWaitableTimer(NULL, FALSE, NULL);
LARGE_INTEGER liStartTime;
liStartTime.QuadPart = -(5 * 1000 * 1000 * 10);
SetWaitableTimer(g_hWaitableTimer, &liStartTime, 0, ApcCompletionRoutine, NULL, FALSE);
SleepEx(INFINITE, TRUE); // 关键
CloseHandle(hThread);
CloseHandle(g_hWaitableTimer);
MSG msg;
HACCEL hAccelTable;
// 初始化全局字符串
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_WAITABLETIMERTEST, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// 执行应用程序初始化:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WAITABLETIMERTEST));
// 主消息循环:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
标签:api hand com app pts word timer init hello
原文地址:http://www.cnblogs.com/xiaobingqianrui/p/6654840.html