PB seems to have a problem with the API 'GetFileVersionInfo()' function call.
Code: Select all
k$="c:\temp\test.txt"+Chr(0)
j$ = Space(256)
GetFileVersionInfo_(@k$,0,256,@j$)
Debug j$
Any suggestions most welcome.
RichardL
Code: Select all
k$="c:\temp\test.txt"+Chr(0)
j$ = Space(256)
GetFileVersionInfo_(@k$,0,256,@j$)
Debug j$
Code: Select all
k$="c:\temp\test.txt"+Chr(0)
j$ = Space(256)
OpenLibrary(0,"version.dll")
CallFunction(0,"GetFileVersionInfoA",@k$,0,256,@j$)
CloseLibrary(0)
Debug j$
Code: Select all
Procedure.s GetFileVersionInfo(File.s)
;
iLibrary.l
;
iFunctionInfo.l
iFunctionSize.l
iFunctionQry.l
;
HoldString.s
;
HoldReturn.s
;
*HoldVersion.l
;
HoldResult.l
;
HoldBuffer.l
;
HoldEmpty.l
;
*HoldInfo.VS_FIXEDFILEINFO
;
iLibrary = OpenLibrary(#PB_Any, "version.dll")
;
If iLibrary
;
iFunctionInfo = IsFunction(iLibrary, "GetFileVersionInfoA")
iFunctionSize = IsFunction(iLibrary, "GetFileVersionInfoSizeA")
iFunctionQry = IsFunction(iLibrary, "VerQueryValueA")
;
If iFunctionInfo And iFunctionSize And iFunctionQry
;
HoldBuffer = CallFunctionFast(iFunctionSize, @File, @HoldEmpty)
;
HoldReturn = Space(HoldBuffer)
;
HoldResult = CallFunctionFast(iFunctionInfo, File, 0, HoldBuffer, @HoldReturn)
;
HoldResult = CallFunctionFast(iFunctionQry, @HoldReturn, "\", @HoldEmpty, @HoldBuffer)
;
*HoldInfo = AllocateMemory(SizeOf(VS_FIXEDFILEINFO))
;
CopyMemory(HoldEmpty, *HoldInfo, SizeOf(VS_FIXEDFILEINFO))
;
HoldString = Str(*HoldInfo\dwFileVersionMS >> 16 & $FFFF) + "." + Str(*HoldInfo\dwFileVersionMS & $FFFF) + "." + Str(*HoldInfo\dwFileVersionLS >> 16 & $FFFF) + "." + Str(*HoldInfo\dwFileVersionLS & $FFFF)
;
CloseLibrary(iLibrary)
;
FreeMemory(*HoldInfo)
;
HoldReturn = Space(0)
;
If HoldResult
;
ProcedureReturn HoldString
;
Else
;
ProcedureReturn ""
;
EndIf
;
EndIf
;
CloseLibrary(iLibrary)
;
EndIf
;
EndProcedure
Correct, program folder (as far as I know) then fallback to system folder.RichardL wrote:My understanding is that when a library is opened without a complete path name the OS looks in two places; (1) the directory the program was launched from and (2) in the System32 directory. Does anyone know if there is a fixed order for this, or alternatively is there a way of finding out which directory the DLL was launched from.
Code: Select all
;name$ contains the name of the module (either a .dll or .exe file).
;If the file name extension is omitted, the default library extension
;.dll is appended. The file name string can include a trailing point
;character (.) to indicate that the module name has no extension.
;The string does not have to specify a path. When specifying a path,
;be sure to use backslashes (\), not forward slashes (/).
;The name is compared (case independently) to the names of modules currently
;mapped into the address space of the calling process.
Procedure.s GetModuleFilePath(name$)
path$=Space(#MAX_PATH)
hndl=GetModuleHandle_(name$)
If hndl
If GetModuleFileName_(hndl,@path$,#MAX_PATH)>0
path$=GetPathPart(path$)
EndIf
EndIf
ProcedureReturn Trim(path$)
EndProcedure
;Returns the path or "" if failed!
Debug GetModuleFilePath("kernel32.dll")
Code: Select all
Procedure.s GetModuleFilePath(name$)
path$=Space(#MAX_PATH)
hndl=GetModuleHandle_(name$)
If hndl
If GetModuleFileName_(hndl,@path$,#MAX_PATH)>0
path$=GetPathPart(path$)
EndIf
EndIf
ProcedureReturn Trim(path$)
EndProcedure
;Returns the path or "" if failed!
OpenLibrary(0,"atl.dll")
MessageRequester("test",GetModuleFilePath("atl.dll"))