>Hi,
>
>I have bought VFP7 but procrastinated. Now I'd like to jump to 8.
>I have 100 users on a LAN, but the executable is on the client, (automatically replaced when there is a new version on the Server).
>
>Can I just write a routine to copy the runtime files from the Server to system 32 on the client and register them the same way as an acivex or a local com?
>
>Thanks
Hi Johathan.
I have a couple of methods that might help. Our framework we use (home grown) automatically registers any DLL or OCX that is plaved in a folder called REGDIR under the application root. The first method (in the INIT of the application class) looks for files in the REGDIR folder. It calls the ShellEcecute method in the same class to actually register the files. The REGSVR32.EXE file must also ne in the folder.
Here is the code in the INIT:
* See if any components need to be registered. If so, then
* do so now.
local lcWinSysDir, lnSize
declare integer GetSystemDirectory in WIN32API ;
string @lcWinSysDir, ;
integer lnSize
lcWinSysDir = space(255)
lnSize = len(lcWinSysDir)
= GetSystemDirectory(@lcWinSysDir, lnSize)
lcWinSysDir = alltrim(lcWinSysDir)
*-- Strip the null off of the end of the string that was returned.
lcWinSysDir = addbs(left(lcWinSysDir, len(lcWinSysDir) - 1))
local array laReg[1]
local lcRegDir, lnFiles, lnCount, lcFile, lcRegFile, lcWinSysFile, ;
lcRegSvr, lcDir
lcRegDir = addbs(sys(5) + curdir()) + "REGDIR\"
lnFiles = 0
lnCount = 0
lcFile = ""
lcRegFile = ""
lcWinSysFile = ""
lcRegSvr = lcRegDir + "REGSVR32.EXE"
lcDir = '"' + lcRegDir + '"'
* If there is a REGDIR folder and it contains the REGSVR32.EXE
* program, then check to see if there are any DLL's or OCX's
* that need to be registered. If a DLL or OCX is already in the
* Windows System directory, then assume it has already been
* registered. Otherwise, copy the file to the Windows System
* folder and register the copy there.
if directory(&lcDir)
lcRegSvr = '"' + lcRegDir + "REGSVR32.EXE" + '"'
if file(&lcRegSvr)
lcFile = '"' + lcRegDir + "*.OCX" + '"'
lnFiles = adir(laReg, &lcFile)
if lnFiles > 0
for lnCount = 1 to lnFiles
lcFile = lcRegDir + upper(alltrim(laReg[lnCount, 1]))
lcRegFile = '"' + lcFile + '"'
lcWinSysFile = '"' + lcWinSysDir + alltrim(laReg[lnCount, 1]) + '"'
if not file(&lcWinSysFile)
copy file &lcRegFile to &lcWinSysFile
lcRegSvr = lcRegDir + "REGSVR32.EXE"
THIS.ShellExecute(lcRegSvr, "", "", " /s " + lcWinSysFile, .F., .F.)
endif
endfor
endif
lcFile = '"' + lcRegDir + "*.DLL" + '"'
lnFiles = adir(laReg, &lcFile)
if lnFiles > 0
for lnCount = 1 to lnFiles
lcFile = lcRegDir + upper(alltrim(laReg[lnCount, 1]))
lcRegFile = '"' + lcFile + '"'
lcWinSysFile = '"' + lcWinSysDir + alltrim(laReg[lnCount, 1]) + '"'
if not file(&lcWinSysFile)
copy file &lcRegFile to &lcWinSysFile
lcRegSvr = lcRegDir + "REGSVR32.EXE"
THIS.ShellExecute(lcRegSvr, "", "", " /s " + lcWinSysFile, .F., .F.)
endif
endfor
endif
endif
endif
Here is the code in the SHELLEXECUTE method:
**************************************************************************
* ShellExecute. Opens a file in the application that it's associated
* with or runs a specified program.
*
* Parameters:
*
* 1) Name of the file to open or program to run (full path). Required.
*
* 2) The "working directory". Optional - defaults to blank string.
*
* 3) The operation to perform. Optional - defaults to "Open".
*
* 4) The parameters to pass to the program. Optional - defaults to
* a blank string.
*
* 5) Show/No Show application window. Optional - defaults to
* 1 (show). If specified, must be one of the following values:
*
* 0 = Don't show the application window.
* 1 = Show the application window (default).
*
* NOTE: Normally, if opening a file (such as a Word Document or
* Excel spreadsheet, etc.), you will want to show the
* application window. However, if you are running a program like
* PKUNZIP, then you may not want the command window to show.
*
* 6) Show error message on failure. Optional, defaults to .F.
* (don't show). If specified, valid values are:
*
* .T. = Show error message if an error occurs.
* .F. = Don't show an error message if an error occurs (default).
*
* Updates:
*
* - THIS.inShellExecuteStatus (Values over 32 indicate success
* and are an instance handle for the application started.)
*
* Returns:
* (none)
*
**************************************************************************
lparameters tcFileName, tcWorkDir, tcOperation, tcParameters, tnShow, ;
tlShowError
local lcFileName, lcWorkDir, lcOperation, lcParameters, lnShow, ;
llShowError, llOK
lcFileName = ""
lcWorkDir = ""
lcOperation = "open"
lcParameters = ""
lnShow = 1
llShowError = .F.
llOK = .T.
if empty(tcFileName)
THIS.inShellExecuteStatus = -1
llOK = .F.
endif
if llOK
lcFileName = alltrim(tcFileName)
lcWorkDir = iif(type("tcWorkDir") = "C", alltrim(tcWorkDir), "")
lcOperation = iif(type("tcOperation") = "C" ;
and (not empty(tcOperation)), alltrim(tcOperation), "Open")
lcParameters = iif(type("tcParameters") = "C", ;
alltrim(tcParameters), "")
lnShow = iif(type("tnShow") = "N" and between(tnShow, 0, 1), ;
tnShow, 1)
llShowError = tlShowError
declare integer ShellExecute ;
in SHELL32.DLL ;
integer lnWinHandle,;
string lcOperation,;
string lcFileName,;
string lcParameters,;
string lcWorkDir,;
integer lnShow
THIS.inShellExecuteStatus = ShellExecute(0, lcOperation, lcFilename, ;
lcParameters, lcWorkDir, lnShow)
if llShowError
THIS.ShowShellExecuteError()
endif
endif
return
Charlie Parker
cparker@fowlersoftware.com
www.fowlersoftware.com