I noticed this typo in GetFileType
Quote
Example
#INCLUDE ONCE "Afx/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM cwsFileType AS CWSTR = pFileSys.FileType("C:\MyPath\MyFile.txt")
S/B "pFileSys.
GetFileType("C:\MyPath\MyFile.txt")"
Also, I am unable to get pFileSys.GetFileVersion("somefile") to return anything. I test for the existence of the file first.
Thanks, I have corrected the typo.
> Also, I am unable to get pFileSys.GetFileVersion("somefile") to return anything. I test for the existence of the file first.
This means that the file has no version nformation.
Try
DIM pFileSys AS CFileSys
print pFileSys.GetFileVersion("c:\windows\system32\scrrun.dll")
Thanks José,
I read this Remark "The GetFileVersion method returns a zero-length string ("") if cwsFileName does not end with the named component." as meaning that IF the return value does not end with the named component, the value would be a CBSTR that was something other than "". The clue for me should have been the Example
IF LEN(cbsVersion) THEN
MSGBOX "File version: " & cbsVersionELSE
'' This line:
MSGBOX "No version information available"
END IF
Live and learn...
Some files, mainly .exe and .dll files, include a resource file with version information, e.g.
//=============================================================================
// Application Version Information.
//=============================================================================
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 0, 4, 0
PRODUCTVERSION 1, 0, 4, 0
FILEOS VOS_WINDOWS32
FILETYPE VFT_APP
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "José Roca\0"
VALUE "FileDescription", "Application\0"
VALUE "FileVersion", "Version 1.04\0"
VALUE "InternalName", "CSED\0"
VALUE "OriginalFilename", "CSED.EXE\0"
VALUE "LegalCopyright", "Coded in 2011 by José Roca\0"
VALUE "LegalTrademarks", "\0"
VALUE "ProductName", "MDI Editor for PowerBasic\0"
VALUE "ProductVersion", "1.04\0"
VALUE "Comments", "Scintilla based control editor for PowerBasic, Written in PB/WIN 10\0"
END
END
END
The value specified in
VALUE "FileVersion", "Version 1.04\0"
is what is returned by this method.
Much appreciated, thanks.
Hi José
DIM cIni AS CInifile = "C:\WinFBE_Suite\Settings\WinFBE.ini"
DIM wszName AS WSTRING * 260
'' This line causes crash:
wszName = cIni.GetString( "", "WinFBEversion", "No Value" )
It would appear to be the blank [Section] field "". Put any value in [Section] and the code functions as designed.
It crashes with 64-bit. This version of the compiler seems to have a problem when passing empty null terminated strings. I have added checkings to not call WritePrivateProfileStringW if the passed parameters are empty strings.
That solved the crashing, thanks!