什么是内核对象?参考这里:

http://www.cnblogs.com/vivilisa/archive/2009/03/09/1407277.html

 

使用命名对象来防止运行一个应用程序的多个实例

代码如下:

 



int WINAPI _tWinMain(HINSTANCE hInstExe, HINSTANCE, PTSTR pszCmdLine, int nCmdShow)
{
    HANDLE h 
= CreateMutex(NULL, FALSE, TEXT("{b2e42b57-8ee3-11df-bb01-846a855c3e23}"));
    
    
if(GetLastError() == ERROR_ALREADY_EXISTS)
    {
        CloseHandle(h);
        
return(0);
    }

    
// This is the first instance of this application running.
    
// ...
    
// Before exiting, close the object.
    CloseHandle(h);
    
return(0);
}

 

 

相关文章:

  • 2022-01-11
  • 2022-12-23
  • 2022-02-13
  • 2021-10-07
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2022-01-01
  • 2022-12-23
  • 2021-10-03
  • 2021-06-25
相关资源
相似解决方案