**********************************************************
* Author : William GC Steinford *
**********************************************************
PROCEDURE RunAndBuildISE
LPARAMETERS tcIseFile
lcISE_Prog = "c:\Program Files\InstallShield\Express 5.0 Visual FoxPro\IsIDE.exe"
DECLARE INTEGER CreateProcess IN kernel32;
INTEGER lpApplicationName, ;
STRING @ lpCommandLine, ;
INTEGER lpProcessAttributes,;
INTEGER lpThreadAttributes,;
INTEGER bInheritHandles,;
INTEGER dwCreationFlags,;
INTEGER lpEnvironment,;
STRING lpCurrentDirectory,;
STRING lpStartupInfo,;
STRING @ lpProcessInformation
DECLARE LONG WaitForSingleObject in win32api INTEGER hHandle, LONG dwMilliseconds
DECLARE INTEGER GetExitCodeProcess in win32api INTEGER hProcess, INTEGER @ nExitCode
#DEFINE SW_SHOW 5
#DEFINE STILL_ACTIVE 0x103
LOCAL lcStartInfo, lcProcessInfo, lcCmd, lhProcess, lnExitCode, ;
llBuilt
lcStartInfo = GetStartupInfo()
lcProcessInfo = repl( chr(0), 12 )
*!* typedef struct _PROCESS_INFORMATION { HANDLE hProcess
*!* HANDLE hThread
*!* DWORD dwProcessId
*!* DWORD dwThreadId } PROCESS_INFORMATION
* MSDN Notes: If both AppName and CmdLine are provided, then they are both treated as *lp
* (ie: Pointer to Pointer to String, instead of just lp: Pointer to String)
* When I specify both, it seems that appname works but commandline doesn't.
* MSDN Notes also: If one is null (AppName or CmdLine) then both are expected to be
* given in the other parameter.
* So that's what we do. And it works.
lcCmd = ["]+lcISE_Prog+[" "]+tcIseFile+["]
if 0=CreateProcess( 0, @lcCmd, 0,0,0,0,0,0, ;
lcStartInfo, @lcProcessInfo )
*?"Could not create process"
RETURN -1
endif
lhProcess = Buf2dword( left( lcProcessInfo, 4 ) )
lnExitCode = STILL_ACTIVE
lnRes = 1
llBuilt = .f.
do while lnExitCode=STILL_ACTIVE or lnRes=0
WaitForSingleObject(lhProcess, 500) && 1/2 second
IF NOT llBuilt
IF RelBuildISE( tcIseFile )
llBuilt = .t.
ENDIF
ENDIF
lnExitCode = -2
lnRes = GetExitCodeProcess(lhProcess, @lnExitCode) && non-zero means success.
if lnExitCode=STILL_ACTIVE
if InKey()=27 && Cancel waiting
RETURN -3
endif
endif
enddo
RETURN iif(lnRes=0,-2,lnExitCode)
ENDPROC
**************************************
FUNCTION RelBuildISE( tcIseFile )
LOCAL lcIseFile, lnISE, lnMenuArea, lnToolbar
lcIseFile = JUSTSTEM(tcIseFile)
*#define WM_LBUTTONDOWN 0x0201
*#define WM_LBUTTONUP 0x0202
DECLARE INTEGER FindWindow in win32api as apiFindWindow ;
INTEGER nClass, STRING cName
DECLARE INTEGER FindWindowEx IN WIN32API as apiFindWindowEx ;
INTEGER hwndParent, ;
integer hwndChildAfter, ;
string @ lpszClass, ;
string @ lpszWindow
Declare INTEGER SendMessage in user32 as apiSendMessage ;
INTEGER hWnd, ;
INTEGER nMsg, ;
INTEGER nParam1, ;
INTEGER nParam2
lnISE = apifindwindow(0,lcIseFile+' - InstallShield Express')
IF lnIse>0
lnMenuArea = -1
lnToolbar = 0
&& sort through all the AfxControlBar42 windows to find the toolbar window
DO WHILE lnMenuArea<>0 AND lnToolbar=0
lnMenuArea = IIF(lnMenuArea<0,0,lnMenuArea)
lnMenuArea = apiFindWindowEx(lnISE,lnMenuArea,'AfxControlBar42',0)
lnToolbar = apiFindWindowEx(lnMenuArea,0,'Afx:400000:8:10011:10:0','Standard')
ENDDO
addLog( 'hndISE='+TRANSFORM(lnIse)+', hndMenu='+TRANSFORM(lnMenuArea)+', hndTbr='+TRANSFORM(lnToolbar) )
IF lnToolbar>0
apiSendMessage( lnToolbar, 0x0201, 0x01, 0x000B0115 )
apiSendMessage( lnToolbar, 0x0202, 0x00, 0x000B0115 )
RETURN .T.
ENDIF
ENDIF
RETURN .F.
ENDFUNC