2013-07-04 54 views

回答

0

創建一個具有唯一名稱的信號量。然後在卸載程序中檢查信號量是否存在,如果是則表示應用程序正在運行。

在你的程序:

CreateSemaphore(NULL, 0, 1, "Some unique string of your choice") ; 

在您的卸載程序:

BOOL isrunning = FALSE ; 
    HANDLE hsem = CreateSemaphore(NULL, 0, 1, "Some unique string of your choice") ; 

    if (hsem != NULL) 
    { 
    if (GetLastError() == ERROR_ALREADY_EXISTS) 
     isrunning = TRUE ; 

    CloseHandle(hsem) ; 
    } 
+0

感謝@邁克爾瓦爾茲 –

相關問題