※ 引述《BoJu.bbs@csie.nctu.edu.tw (Nick)》之銘言:
> 若不希望同一個程式在Windows下被執行兩次,在程式內如何
> 作這樣的判斷?
> 謝謝
HWND GetRunningWindow(class)
char_t *class;
{
HWND hwndOther;
hwndOther = FindWindow(CLASS, NULL);
if (IsWindow(hwndOther))
{
HWND hwndPopup;
hwndPopup = GetLastActivePopup(hwndOther);
return (IsWindow(hwndPopup) ? hwndPopup : hwndOther);
}
return NULL;
}
// In the start of WinMain() call GetRunningWindow("your_class_...")
// If it return NULL, it will be your program's first instance.
--
※ Origin: 楓橋驛站<bbs.cs.nthu.edu.tw> ◆ From: thcs-9.cs.nthu.edu.tw