Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // clang-cl main.cpp -Fe -link user32.lib
- #include <windows.h>
- #include <iostream>
- #define _SECOND 10000000
- VOID CALLBACK LogFunc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
- {
- // Formal parameters not used in this example.
- UNREFERENCED_PARAMETER(lpArg);
- UNREFERENCED_PARAMETER(dwTimerLowValue);
- UNREFERENCED_PARAMETER(dwTimerHighValue);
- std::cout << "hello from LogFunc\n";
- }
- VOID CALLBACK HelloFunc(ULONG_PTR dwParam)
- {
- std::cout << "hello from the APCFunc " << dwParam << "\n";
- }
- int main(void)
- {
- uint32_t counter = 100;
- LARGE_INTEGER liDueTime;
- liDueTime.LowPart = (DWORD)(-5 * _SECOND & 0xFFFFFFFF);
- liDueTime.HighPart = (LONG)(-5 * _SECOND >> 32);
- HANDLE hTimer = ::CreateWaitableTimer(NULL, FALSE, NULL);
- ::SetWaitableTimer(hTimer, &liDueTime, 2000, LogFunc, &counter, FALSE);
- for (uint16_t i = 0; i < 2; ++i)
- {
- ::QueueUserAPC(HelloFunc, ::GetCurrentThread(), i);
- }
- for (; counter < 1000; counter += 100)
- {
- ::SleepEx(INFINITE, TRUE);
- }
- ::CloseHandle(hTimer);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement