December 16th, 2002, 10:54 PM
Hi does anyone know of an easy way to determine if a process already exists in a windows system??
I am writting an app to run using the screen saver utility. The app stays active until explicitly closed. If the mouse is moved the screen saver utility will automatically kick in and start again, hence multiple copies of the app can execute, something I wish to prevent.
December 16th, 2002, 11:21 PM
December 17th, 2002, 11:04 PM
Another simple method not mentioned
Place this code at the begining of your winmain
Free the HANDLE at close with
hMapping = CreateFileMapping((HANDLE)0xffffffff, NULL, PAGE_READONLY, 0, 32, szAppName);
if (hMapping) // Check to see if app is already running, if so exit
if (GetLastError() == ERROR_ALREADY_EXISTS)
sprintf(sBuffer,"%s is already running. Create another [YES] or exit [NO].",szAppName);
if(MessageBox(NULL, sBuffer, "Error",MB_ICONERROR| MB_YESNO)==IDNO)
MessageBox(NULL, "Error creating file mapping.", "Error",MB_ICONERROR| MB_OK);
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.