Obtaining DLL-specific version information

Most Windows Shell and common controls DLLs implement DllGetVersion function. It allows applications to obtain DLL-specific version information to make sure that required functionality in a DLL is implemented.
The Windows API support class is used to handle Windows API structures.

This is sample code. Add error handling and adjust to your requirements as necessary.

#DEFINE DLLVER_PLATFORM_WINDOWS  1
#DEFINE DLLVER_PLATFORM_NT       2
 
lcDll = "Shell32.dll"
DECLARE INTEGER DllGetVersion IN (lcDll) STRING @pdvi
 
LOCAL lcBuffer
lcBuffer = CHR(20) + REPLICATE(CHR(0), 19)
loWas = NEWOBJECT("WinApiSupport", "WinApiSupport.fxp")
 
IF DllGetVersion(@lcBuffer) = 0
	? "DLL:           " + lcDll
	? "Major version: " + TRANSFORM(loWas.Long2num(SUBSTR(lcBuffer, 5,4)))
	? "Minor version: " + TRANSFORM(loWas.Long2num(SUBSTR(lcBuffer, 9,4)))
	? "Build number:  " + TRANSFORM(loWas.Long2num(SUBSTR(lcBuffer, 13,4)))
	? "Platform:      " + IIF(loWas.Long2num(SUBSTR(lcBuffer, 17,4))=1,"Windows", "WinNT")
ENDIF