VFP stores in EXE/DLL information about what runtime DLL is required to run it.
? VfpVersionFromExeOrDll("C:\Program Files\My Company\MyVfpApplication.exe")
? VfpVersionFromExeOrDll("X:\Somefolder\MyVfpDll.dll")
* VfpVersionFromExeOrDll.PRG
FUNCTION VfpVersionFromExeOrDll
LPARAMETERS tcExeDllName
LOCAL lcSig, lnHandle, lcVersion, lcBuffer, lnPos, lcSigMT
lnHandle = FOPEN(tcExeDllName, 0)
IF lnHandle < 0
? FERROR()
RETURN "Unable to Open file + '" + tcExeDllName + "'"
ENDIF
lcSig = "VisualFoxProRuntime."
lcSigMT = "VisualFoxProRuntimeMT."
lcVersion = "(Unknown)"
* Read first 64KB
lcBuffer = FREAD(lnHandle, 65535)
* Check for regular runtime signature
lnPos = AT(lcSig, lcBuffer)
IF lnPos > 0
*lcVersion = "Vfp " + STRTRAN(SUBSTR(lcBuffer, lnPos + LEN(lcSig),2), CHR(0), "") + ".0"
lcVersion = "Vfp" + STRTRAN(SUBSTR(lcBuffer, lnPos + LEN(lcSig),2), CHR(0), "") + "R.dll"
ELSE
* Check for Multithreaded (MT) runtime signature
lnPos = AT(lcSigMT, lcBuffer)
IF lnPos > 0
*lcVersion = "Vfp MT " + STRTRAN(SUBSTR(lcBuffer, lnPos + LEN(lcSigMT),2), CHR(0), "") + ".0"
lcVersion = "Vfp" + STRTRAN(SUBSTR(lcBuffer, lnPos + LEN(lcSigMT),2), CHR(0), "") + "T.dll"
ENDIF
ENDIF
=FCLOSE(lnHandle)
RETURN lcVersion
Niciun comentariu:
Trimiteți un comentariu