(SST) ShlWAPI.pas Version 1.08

Developer Reference
TDllGetVersionProc Type Definition
Procedural type that defines the Microsoft recommendation and de-facto standard for a function that returns the version of a dynamic link library.
Scope
Global (i.e. pointer variables can be cast to this type and declared in any unit that uses/includes the unit in which the type was defined/declared).
Syntax
TYPE TDllGetVersionProc = FUNCTION(dllversioninfop : PDllVersionInfo) : HRESULT;
Parameters
dllversioninfop [in] Pointer to, or address of a record/structore of type TDllVersionInfo or TDllVersionInfo2. .
Return Values
Returns S_OK (= 0) on success and, typically, a COM-defined error code on failure.
Remarks
This type is commonly used to type-cast a pointer variable to the entry point of the DllGetVersion function, previously acquired by means of the Windows, API function GetProcAddress, as a DllGetVersion function. Alternatively, it can also be used declare a variable in which to store the function's address directly. In this case, the function can subsequently be called by means of this variable without a type-cast.
Because the DllGetVersion function is an optional function that is not exported by all dlls, its existence and accessibility in both system and third party dlls can/should not be taken for granted and therefore has to be confirmed by means of the Windows, API function GetProcAddress, prior to calling the function itself.
Example(s)
... Procedure CallDllGetVersion1(); Var dllhandle : HMODULE; Var dllverinforec : TDllVersionInfo; Var procaddr : POINTER; Var getverresult : HRESULT; begin dllhandle := 0; procaddr := NIL; FlllChar(dllverinforec, SizeOf(dllverinforec), #0); getverresult := 0; dllhandle := LoadLibrary('MyExampleDll.dll'); if (modulehandle <> 0) and (modulehandle <> INVALID_HANDLE_VALUE) then begin //Note, that the function name is case-sesitive ! procaddr := GetProcAddress(dllhandle, 'DllGetVersion'); if procaddr <> nil then begin dllverinforec.cbSize := SizeOf(dllverinforec); getverresult := TDllGetVersionProc(procaddr))(@dllverinforec); FreeLibrary(dllhandle); end; end; end; ... Procedure CallDllGetVersion2(); Var modulehandle : HMODULE; Var dllgetverfunc : TDllGetVersionProc; Var dllverinfo2rec : TDllVersionInfo2; Var getverresult : HRESULT; begin modulehandle := 0; procaddr := NIL; FlllChar(dllverinfo2rec, SizeOf(dllverinfo2rec), #0); getverresult := 0; //The following line assumes that the dll was already loaded //somewhere else in the program modulehandle := GetModuleHandle('MyExampleDll.dll'); if (modulehandle <> 0) and (modulehandle <> INVALID_HANDLE_VALUE) then begin //Don't forget that the function name is case-sesitive ! dllgetverfunc := GetProcAddress(dllhandle, 'DllGetVersion'); if @dllgetverfunc <> nil then begin dllverinfo2rec.info1.cbSize := SizeOf(dllverinfo2rec); getverresult := dllgetverfunc(@dllverinfo2rec); end; end; end;
Requirements
Unit Declared in ShlWAPI.pas
Library ShlWAPI.dcu/ShlWAPI.obj
See Also
TDllVersionInfo, TDllVersionInfo2. MakeDllVerULL, DllGetVersion.
 
Windows APIs: DLLVERSIONINFO, DLLVERSIONINFO2, DllGetVersion, GetProcAddress.

Document/Contents version 1.00
Page/URI last updated on May 04, 2022
 
Copyright © Stoelzel Software Technologie (SST) 2010 - 2017
Suggestions and comments mail to:
webmaster@stoelzelsoftwaretech.com