Tips of Windows Programming
2010年6月11日
窗口总在最前
::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
窗口总保持激活状态, 这段代码可以放在定时器内.
void KeepWindowAlwaysActive(HWND hWnd)
{
HWND hCurWnd = NULL;
DWORD lMyID = 0;
DWORD lCurID = 0;
hCurWnd = ::GetForegroundWindow();
if(hCurWnd != hWnd)
{
lMyID = ::GetCurrentThreadId();
lCurID = ::GetWindowThreadProcessId(hCurWnd, NULL);
::AttachThreadInput(lMyID, lCurID, TRUE);
::SetForegroundWindow(hWnd);
::AttachThreadInput(lMyID, lCurID, FALSE);
}
}
怎么跟自旋锁打交道
The code within a critical region guarded by an spin lock must neither be pageable nor make any references to pageable data.
The code within a critical region guarded by a spin lock can neither call any external function that might access pageable data or raise an exception, nor can it generate any exceptions.
The caller should release the spin lock with KeReleaseSpinLock as quickly as possible.

近期评论