在98下写了个服务程序,把它放到注册表的RunServices键下,但是我注销后,程序起不了,原来注销后启动的是Run下程序,怎样只启动一个程序
同上 问题点数:200、回复次数:1Top
1 楼akiy(winexec)回复于 2003-01-02 11:29:32 得分 200
只写在run 底下就已经够了
如果非要都写就加个锁
BOOL CYourApp::InitInstance()
{
if(FirstInstance())
{
return FALSE;
}
..............
}
BOOL CYourApp::FirstInstance()
{
BOOL bFound = FALSE;
// Try to create a mutex with the app's name
HANDLE hMutexOneInstance = ::CreateMutex(NULL,TRUE,_T(AfxGetAppName()));
// Already there...means that we are already running an instance
if(::GetLastError() == ERROR_ALREADY_EXISTS)
bFound = TRUE;
// Release the mutex
if(hMutexOneInstance)
::ReleaseMutex(hMutexOneInstance);
return(bFound);
}
Top




