OPTIONS "C_CALL"
NUMERIC DIGITS 10
OPTIONS "WINFUNC NOSOURCE"
DO
FUNCDEF("GetModuleHandle", "void *, str", "kernel32", , "O")
FUNCDEF("FreeLibrary", "void, void", "kernel32")
FUNCDEF("LoadLibrary", "void *, str", "kernel32", , "O")
FUNCDEF("GetFileVersionInfoSize", "32u, str, 32u * stor", "version")
FUNCDEF("GetModuleFileName", "32u, void, str[260] stor, 32u", "kernel32")
FUNCDEF("GlobalAlloc", "void *, 32u, 32u", "kernel32", , "O")
FUNCDEF("GlobalFree", "void, void", "kernel32")
FUNCDEF("GetFileVersionInfo", "32u, str, 32u, 32u, void", "version")
FUNCDEF("GetLastError", "32u", "kernel32")
fixedfileinfo = "32u, 32u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 32u, 32u, 32u, 32u, 32u, 16u, 16u, 16u, 16u"
fixedfileptr = "struct FIXEDFILEINFO *"
FUNCDEF("GetFixedFileVersInfo", "32u, void, str, struct FIXEDFILEPTR stor, 32u * stor", "version", "VerQueryValue")
translateinfo = "char[4]"
transinfoptr = "struct TRANSLATEINFO *"
FUNCDEF("VerQueryValue", "32u, void, str, struct TRANSINFOPTR stor, 32u * stor", "version")
infostr = "str *"
FUNCDEF("VerQueryStr", "32u, void, str, struct INFOSTR stor, 32u * stor", "version", "VerQueryValue")
CATCH FAILURE
CONDITION('M')
RETURN
END
myexename = SEARCHPATH("%WIN%") || "notepad.exe"
libloaded = 0
module = getmodulehandle(myexename)
IF module == "" THEN DO
module = loadlibrary(myexename)
IF module == "" THEN DO
infoerr1:
err = getlasterror()
SAY "Can't retrieve info about" myexename || "." || '0D0A'x || "Error #" || err
SAY UNIXERROR(err)
RETURN
END
libloaded = 1
END
LENGTH = getmodulefilename(module, filename, 260 )
IF LENGTH == 0 THEN DO
infoerr2:
IF libloaded == 1 THEN freelibrary(module)
SIGNAL infoerr1
END
LENGTH = getfileversioninfosize(filename, junk)
IF LENGTH == 0 THEN SIGNAL infoerr2
versioninfo = CONVERTDATA(0,"", "char[" || LENGTH || "]", "A")
IF versioninfo == "" THEN SIGNAL infoerr2
IF getfileversioninfo(filename, , LENGTH, versioninfo) == 0 THEN SIGNAL infoerr2
IF getfixedfileversinfo(versioninfo, "\", fixedfileinfo, length) == 0 THEN SIGNAL infoerr2
SAY "File version =" fixedfileinfo.1.4 || "." fixedfileinfo.1.3 || "." fixedfileinfo.1.6 || "." fixedfileinfo.1.5
SAY "Product version =" fixedfileinfo.1.8 || "." fixedfileinfo.1.7 || "." fixedfileinfo.1.10 || "." fixedfileinfo.1.9
SELECT
WHEN fixedfileinfo.1.14 == 1 THEN SAY "Application"
WHEN fixedfileinfo.1.14 == 2 THEN SAY "Dynamic Link Library"
WHEN fixedfileinfo.1.14 == 3 THEN DO
SELECT
WHEN fixedfileinfo.1.15 == 1 THEN SAY "Printer driver"
WHEN fixedfileinfo.1.15 == 2 THEN SAY "Keyboard driver"
WHEN fixedfileinfo.1.15 == 3 THEN SAY "Language driver"
WHEN fixedfileinfo.1.15 == 4 THEN SAY "Display driver"
WHEN fixedfileinfo.1.15 == 5 THEN SAY "Mouse driver"
WHEN fixedfileinfo.1.15 == 6 THEN SAY "Network driver"
WHEN fixedfileinfo.1.15 == 7 THEN SAY "System driver"
WHEN fixedfileinfo.1.15 == 8 THEN SAY "Installable driver"
WHEN fixedfileinfo.1.15 == 9 THEN SAY "Sound driver"
WHEN fixedfileinfo.1.15 == 10 THEN SAY "Comm driver"
WHEN fixedfileinfo.1.15 == 11 THEN SAY "Input driver"
OTHERWISE SAY "Unknown type of driver"
END
END
WHEN fixedfileinfo.1.14 == 4 THEN DO
SELECT
WHEN fixedfileinfo.1.15 == 1 THEN SAY "Raster Font"
WHEN fixedfileinfo.1.15 == 2 THEN SAY "Vector Font"
WHEN fixedfileinfo.1.15 == 3 THEN SAY "Truetype Font"
OTHERWISE SAY "Unknown type of font"
END
END
WHEN fixedfileinfo.1.14 == 5 THEN SAY "16-bit driver"
WHEN fixedfileinfo.1.14 == 6 THEN NOP
WHEN fixedfileinfo.1.14 == 7 THEN SAY "Compiler lib"
OTHERWISE SAY "Unknown type of file"
END
SELECT
WHEN fixedfileinfo.1.13 == 1 THEN SAY "For 16-bit Windows"
WHEN fixedfileinfo.1.13 == 2 THEN SAY "For 16-bit OS/2 Presentation Manager"
WHEN fixedfileinfo.1.13 == 3 THEN SAY "For 32-bit OS/2 Presentation Manager"
WHEN fixedfileinfo.1.13 == 4 THEN SAY "For 32-bit Windows"
WHEN fixedfileinfo.1.13 == 65536 THEN SAY "For MS-DOS"
WHEN fixedfileinfo.1.13 == 131072 THEN SAY "For 16-bit OS/2 (command line)"
WHEN fixedfileinfo.1.13 == 196608 THEN SAY "For 32-bit OS/2 (command line)"
WHEN fixedfileinfo.1.13 == 262144 THEN SAY "For 32-bit Windows (command line)"
WHEN fixedfileinfo.1.13 == 65537 THEN SAY "For MS-DOS or 16-bit Windows"
WHEN fixedfileinfo.1.13 == 65540 THEN SAY "For MS-DOS or 32-bit Windows"
WHEN fixedfileinfo.1.13 == 131074 THEN SAY "For 16-bit OS/2"
WHEN fixedfileinfo.1.13 == 196611 THEN SAY "For 32-bit OS/2"
WHEN fixedfileinfo.1.13 == 262148 THEN SAY "For Windows NT/2000/XP"
OTHERWISE SAY "For unknown operating system"
END
IF verqueryvalue(versioninfo, "\VarFileInfo\Translation", translateinfo, length) == 0 THEN SIGNAL infoerr2
translateinfo = "\StringFileInfo\" || VALUEIN(translateinfo.1.1, 1, 2, 'HV') || VALUEIN(translateinfo.1.1, 3, 2, 'HV') || "\"
IF verquerystr(versioninfo, translateinfo || "CompanyName", NAME, length) == 0 THEN SIGNAL infoerr2
SAY "company name =" name.1
IF verquerystr(versioninfo, translateinfo || "ProductName", NAME, length) == 0 THEN SIGNAL infoerr2
SAY "product name =" name.1
IF verquerystr(versioninfo, translateinfo || "ProductVersion", NAME, length) == 0 THEN SIGNAL infoerr2
SAY "product version =" name.1
IF verquerystr(versioninfo, translateinfo || "LegalCopyRight", NAME, length) == 0 THEN SIGNAL infoerr2
SAY "copyright information =" name.1
IF verquerystr(versioninfo, translateinfo || "OriginalFileName", NAME, length) == 0 THEN SIGNAL infoerr2
SAY "original file name =" name.1
IF verquerystr(versioninfo, translateinfo || "FileDescription", NAME, length) == 0 THEN SIGNAL infoerr2
SAY "file description =" name.1
IF verquerystr(versioninfo, translateinfo || "FileVersion", NAME, length) == 0 THEN SIGNAL infoerr2
SAY "file version =" name.1
IF verquerystr(versioninfo, translateinfo || "InternalName", NAME, length) == 0 THEN SIGNAL infoerr2
SAY "internal name =" name.1
CALL CONVERTDATA(versioninfo,"",,"=")
IF libloaded == 1 THEN freelibrary(module)
|
|