Sorry.
You are right... again...
There is a solution using a mutex but I don't remember because all the programs don't create any window.
Happily someone created backups...
Here is my (old) solution:
int PASCAL WinMain(HINSTANCE __hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
{
INITCOMMONCONTROLSEX _Icc ;
WNDCLASS _Wc ;
HWND _hWnd ;
MSG _Msg ;
HANDLE _hMutex ;
char _szTmp[1024] ;
_hMutex = NULL ;
_hMutex = OpenMutex(SYNCHRONIZE,FALSE,szProgramTitle) ;
if(_hMutex)
{
Error(NULL,"Only one instance can run at a time!") ;
ReleaseMutex(_hMutex) ;
CloseHandle(_hMutex) ;
return (FALSE) ;
}
_hMutex = CreateMutex(0,0,szProgramTitle) ;
hInstance = __hInstance ;
SetErrorMode(SEM_FAILCRITICALERRORS) ;
GetModuleFileName(hInstance,szProgramPathAndName,MAX_PATH) ;
lstrcpy(_szTmp,szProgramPathAndName) ;
lstrcpy(szProgramName,PathFindFileName(_szTmp)) ;
*(PathFindFileName(_szTmp)) = '\0' ;
lstrcpy(szProgramFolder,_szTmp) ;
SystemParametersInfo(SPI_GETWORKAREA,0,&RcWorkArea,0) ;
_Icc.dwSize = sizeof(_Icc) ;
_Icc.dwICC = ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES ;
InitCommonControlsEx(&_Icc) ;
hRichEdit = LoadLibrary(szRichEditV4) ;
if(!hRichEdit)
{
Error(NULL,"Please update your RichEdit library to version 4.1 at less!") ;
return (TRUE) ;
}
uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING) ;
hDlgFind = NULL ;
_Wc.lpszClassName = szProgramClass ;
_Wc.lpfnWndProc = MainWndProc ;
_Wc.style = CS_OWNDC|CS_VREDRAW|CS_HREDRAW|CS_DROPSHADOW ;
_Wc.hInstance = hInstance ;
_Wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDR_ICO_MAIN)) ;
_Wc.hCursor = LoadCursor(NULL,IDC_ARROW) ;
_Wc.hbrBackground =(HBRUSH)(COLOR_WINDOW + 1) ;
_Wc.lpszMenuName = MAKEINTRESOURCE(IDR_MNU_MAIN) ;
_Wc.cbClsExtra = 0 ;
_Wc.cbWndExtra = 256 ;
if(!RegisterClass(&_Wc))
return (TRUE) ;
_Wc.lpszClassName = szNewFileClass ;
_Wc.lpfnWndProc = E00_WndProc ;
_Wc.hIcon = NULL ;
_Wc.lpszMenuName = NULL ;
if(!RegisterClass(&_Wc))
return (TRUE) ;
_Wc.lpszClassName = szSavedFileClass ;
_Wc.lpfnWndProc = E01_WndProc ;
_Wc.hIcon = NULL ;
_Wc.lpszMenuName = NULL ;
if(!RegisterClass(&_Wc))
return (TRUE) ;
_hWnd = CreateWindowEx(WS_EX_ACCEPTFILES|WS_EX_CLIENTEDGE|WS_EX_LEFT|WS_EX_CLIENTEDGE|WS_EX_WINDOWEDGE,
szProgramClass,szProgramTitle,
WS_BORDER|WS_CAPTION|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SYSMENU|WS_SIZEBOX|WS_SYSMENU|WS_VISIBLE,
RcWorkArea.left,RcWorkArea.top,RcWorkArea.right - RcWorkArea.left,RcWorkArea.bottom - RcWorkArea.top,
NULL,NULL,hInstance,NULL) ;
if(!_hWnd)
return (TRUE) ;
ShowWindow(_hWnd,nCmdShow) ;
UpdateWindow(_hWnd) ;
while(GetMessage(&_Msg,NULL,0,0))
{
if(!IsDialogMessage(hDlgFind,&_Msg))
{
TranslateMessage(&_Msg) ;
DispatchMessage(&_Msg) ;
}
}
FreeLibrary(hRichEdit) ;
ReleaseMutex(_hMutex) ;
CloseHandle(_hMutex) ;
return (_Msg.wParam) ;
}