|
-
March 5th, 1999, 05:45 AM
#1
Single instance application
Hi,
I need to write an application that will never run in more than one instance.
-
March 13th, 1999, 10:30 AM
#2
Re: Single instance application
Follow the link below and you'll find how to use shared instances.
http://www.codeguru.com/win32/previnst.shtml
If you add also a shared static member of type HWND in which to keep the handler of the main window of the one and only instance, or even the HINSTANCE, you have everything you need.
-
April 4th, 1999, 04:21 AM
#3
Re: Single instance application
Hi ....
Just check for a Named Mutex object, and create one if not exist (ie. first instance).
Hope this will help you
bye
Regards...
Rajan K
-
April 7th, 1999, 03:36 AM
#4
Re: Single instance application
#pragma data_seg("Shared")
LONG g_lUsageCount = -1;
#pragma data_seg()
#pragma comment(linker,"/section:Shared,rws")
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
BOOL fFirstInstance=(InterlockedIncrement(&g_lUsageCount) == 0);
if (fFirstInstance)
{
}
InterlockedDecrement(&g_lUsageCount);
return 1;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|