This is a piece of one of my servers. "IonFilipski-db2orb-v3-server" is just a name for a segment which could be any other names. The segment with this name is shared and variables inside it are accessible to any applications using this segment. If the flag isRunningAlready is true, show server window and exit application. So will be shown only the first instance of application. You should add explicitly /section:IonFilipski-db2orb-v3-server,rws to the linker. RWS means read/write/shared.
.....
#pragma data_seg("IonFilipski-db2orb-v3-server"
//begin of segment
static bool isRunningAlready = false;
HWND hServerWnd = 0;
#pragma data_seg() //end of segment
....
//linker:/section:IonFilipski-db2orb-v3-server,rws
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
if(!isRunningAlready)
{
isRunningAlready = true;
}else
{
if(hServerWnd)
{
ShowWindow(hServerWnd, SW_SHOW);
SetForegroundWindow(hServerWnd);
}
return 0;
}
.....
...
}
Ion Filipski
ICQ: 95034075
AIM: IonFilipski
filipski@excite.com