>LOCAL lhWnd,lhMutex,lcMutexName,llFound,llQuit > >llFound=.f. > >* Declare some API functions >DECLARE Integer GetWindow in win32api Integer,Integer >DECLARE Integer ShowWindow in win32api Integer,Integer >DECLARE Integer GetDesktopWindow in win32api >DECLARE Integer SetForegroundWindow in win32api Integer >DECLARE Integer GetForegroundWindow in win32api >DECLARE Integer CreateMutex in win32api Integer,Integer,String @ >DECLARE Integer CloseHandle in win32api Integer >DECLARE Integer GetLastError in win32api >DECLARE Integer SetProp in win32api Integer,String @,Integer >DECLARE Integer GetProp in win32api Integer,String @ >DECLARE Integer RemoveProp in win32api Integer,String @ >DECLARE Integer IsIconic in win32api Integer > >* Define the Mutex >lcMutexName=const_APPLICATIONNAME+CHR(0) >lhMutex=CreateMutex(0,1,@lcMutexName) > >if GetLastError()=183 > * Mutex Already Exist - locate the original application > lhWnd=GetDesktopWindow() && handle to the desktop > lhWnd=GetWindow(lhWnd,5) && get the first child of the desktop > > do while lhWnd>0 and !llFound && loop until we find the window or run out of windows > if GetProp(lhWnd,@lcMutexName)==1 > if IsIconic(lhWnd)>0 > ShowWindow(lhWnd,9) > endif > SetForegroundWindow(lhWnd) > llFound=.T. > endif > lhWnd=GetWindow(lhWnd,2) && get handle to the next child of the desktop > enddo > CloseHandle(lhMutex) > llQuit=.T. >else > * this assumes our application window is currently active > lhWnd=GetForegroundWindow() > > * To help identify the application window we are adding > * a property to it - which we can later search for > SetProp(lhWnd,@lcMutexName,1) > llQuit=.F. >endif >>
CLOSE ALL Clear ALL #Include MsgBox.H IF fdate('c:\qdms2000\qdms2000.exe',1) < fdate('\\stdsrv01\kdrive\qa\qdms2000\qdms2000.exe',1) IF messagebox("Your QDMS application software requires updating."+chr(13)+chr(13)+; "This process will only take a few seconds."+chr(13)+chr(13)+"Press OK to update, or CANCEL to return to Windows.",; D_Nexclamation+d_nokcancel,"QDMS 2000 Software Update")=d_nok SET safety off COPY file ('\\stdsrv01\kdrive\qa\qdms2000\qdms2000.exe') to ('c:\qdms2000\qdms2000.exe') COPY file ('\\stdsrv01\kdrive\qa\qdms2000\readme.txt') to ('c:\qdms2000\readme.txt') SET safety on IF messagebox("Update complete!"+chr(13)+chr(13)+"Would you like to view the README file for the updated software?",; D_Ninformation+d_nyesno,"QDMS 2000 Software Update")=d_nyes RUN /n1 c:\windows\notepad.exe c:\qdms2000\readme.txt ENDIF ELSE QUIT ENDIF RUN /n c:\qdms2000\qdms2000.exe ELSE RUN /n c:\qdms2000\qdms2000.exe ENDIF