Function udf_IsAppAlreadyRunning() #Define ERROR_ALREADY_EXISTS 183 #Define ERROR_ACCESS_DENIED 5 #Define SW_NORMAL 1 #Define SW_MAXIMIZE 3 #Define SW_RESTORE 9 #Define SW_SHOWDEFAULT 10 #Define GW_HWNDNEXT 2 #Define GW_CHILD 5 Local lnhMutex, lnHwnd, llReturn,lnErrNum * You can define the next two variables in the header file Local lcGUIDForMutex, lcGUIDForScreen, lcGUIDForMutex ="JS_4C45A74D" lcGUIDForScreen ="JS_5D1BD013" lnhMutex = CreateMutex(0, 1, lcGUIDForMutex) lnErrNum = GetLastError() If lnErrNum= ERROR_ALREADY_EXISTS OR lnErrNum = ERROR_ACCESS_DENIED CloseHandle(lnhMutex) llReturn = .T. lnHwnd = GetWindow(GetDesktopWindow(), GW_CHILD) Do While lnHwnd != 0 && loop through all windows If GetProp(lnHwnd, lcGUIDForScreen) = 1 If IsIconic(lnHwnd) ShowWindowsVFP(lnHwnd,SW_RESTORE) Endif BringWindowToTop(lnHwnd) ShowWindowsVFP(lnHwnd,SW_NORMAL) llReturn = .T. Exit Endif lnHwnd = GetWindow(lnHwnd, GW_HWNDNEXT) Enddo CloseHandle(lnHwnd) CloseHandle(lnhMutex) Clear Dlls "BringWindowToTop", "GetDesktopWindow", ; "GetProp", "GetWindow", "ShowWindow", ; "CloseHandle" Else =SetProp(_vfp.HWnd, lcGUIDForScreen, 1) _Screen.AddProperty("MutexHandle",lnhMutex) llReturn = .F. Endif Clear Dlls "CreateMutex", "SetProp" Return (llReturn) Endfunc ******************************************************************************** * Procedure udp_DeclareCommonDLL * Purpose: declaring WinAPI functions for use in application ******************************************************************************** Procedure udp_DeclareCommonDLL ***************************************************************************** * Declaring common functions ***************************************************************************** Declare Integer GetPrivateProfileString In Win32API ; As GetPrivStr ; String cSection, String cKey, String cDefault, String @cBuffer, ; Integer nBufferSize, String posfile Declare Integer WritePrivateProfileString In Win32API ; As WritePrivStr ; String cSection, String cKey, String cValue, String posfile Declare Integer GetDesktopWindow In User32 Declare Integer GetWindow In User32 Integer HWnd, Integer uCmd Declare Integer BringWindowToTop In Win32API Integer HWnd Declare Integer IsIconic In user32 Integer HWnd Declare Integer ShowWindow In Win32API As ShowWindowsVFP ; Integer HWnd, Integer nCmdShow Declare Integer GetProp In User32 Integer HWnd, String lpString Declare Integer SetProp In User32 ; Integer HWnd, String lpString, Integer hData Declare Integer GetLastError In Win32API Declare Integer CloseHandle In Kernel32 Integer hObject Declare Integer CoCreateGuid In ole32 String @pguid Declare Integer StringFromGUID2 In ole32; STRING rguid, String @lpsz, Integer cchMax ***************************************************************************** * Declaring Mutex functions ***************************************************************************** Declare Integer CreateMutex In Win32API ; Integer lpMutexAttributes, Integer bInitialOwner, String lpName Declare Integer ReleaseMutex In Win32API Integer hMutex EndprocBut I never use the killing process of the oldest instance.