PlanetSquires Forums

Support Forums => José Roca Software => Topic started by: SeaVipe on September 05, 2018, 04:49:09 PM

Title: WinFBX - CFileSys Example typo
Post by: SeaVipe on September 05, 2018, 04:49:09 PM
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.


Title: Re: WinFBX - CFileSys Example typo
Post by: José Roca on September 05, 2018, 05:17:55 PM
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")

Title: Re: WinFBX - CFileSys Example typo
Post by: SeaVipe on September 05, 2018, 06:11:45 PM
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...
Title: Re: WinFBX - CFileSys Example typo
Post by: José Roca on September 05, 2018, 07:03:22 PM
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.
Title: Re: WinFBX - CFileSys Example typo
Post by: SeaVipe on September 05, 2018, 09:24:30 PM
Much appreciated, thanks.
Title: Re: WinFBX - CFileSys
Post by: SeaVipe on September 06, 2018, 01:14:09 PM
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.
Title: Re: WinFBX - CFileSys Example typo
Post by: José Roca on September 06, 2018, 03:34:08 PM
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.
Title: Re: WinFBX - CFileSys Example typo
Post by: SeaVipe on September 06, 2018, 03:51:31 PM
That solved the crashing, thanks!