
December 17th, 2002, 10:04 PM
|
|
Offensive Member
|
|
Join Date: Oct 2002
Location: in the perfect world
|
|
Another simple method not mentioned
Place this code at the begining of your winmain
Code:
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)
ExitProcess(1);
}
}
else
{
MessageBox(NULL, "Error creating file mapping.", "Error",MB_ICONERROR| MB_OK);
ExitProcess(1);
}
Free the HANDLE at close with
CloseHandle(hMapping);
__________________
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.
Frank Zappa
|