Click to See Complete Forum and Search --> : Single instance application


Uri
March 5th, 1999, 04:45 AM
Hi,


I need to write an application that will never run in more than one instance.

Bogdan Matasaru
March 13th, 1999, 09:30 AM
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.

Rajan K
April 4th, 1999, 04:21 AM
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

Candan
April 7th, 1999, 03:36 AM
#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;
}