PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: WinFBX - CFileSys Example typo  (Read 268 times)

SeaVipe

  • FireFly3 User
  • Junior Member
  • *
  • Posts: 129
  • Windows 10
WinFBX - CFileSys Example typo
« on: September 05, 2018, 04:19: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.


Logged
Clive Richey

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: WinFBX - CFileSys Example typo
« Reply #1 on: September 05, 2018, 04:47: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

Code: [Select]
DIM pFileSys AS CFileSys
print pFileSys.GetFileVersion("c:\windows\system32\scrrun.dll")

SeaVipe

  • FireFly3 User
  • Junior Member
  • *
  • Posts: 129
  • Windows 10
Re: WinFBX - CFileSys Example typo
« Reply #2 on: September 05, 2018, 05:41: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
Code: [Select]
IF LEN(cbsVersion) THEN
    MSGBOX "File version: " & cbsVersionELSE
    '' This line:   

    MSGBOX "No version information available"
END IF
Live and learn...
Logged
Clive Richey

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: WinFBX - CFileSys Example typo
« Reply #3 on: September 05, 2018, 06:33:22 PM »

Some files, mainly .exe and .dll files, include a resource file with version information, e.g.

Code: [Select]
//=============================================================================
// 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

Code: [Select]
VALUE "FileVersion",      "Version 1.04\0"

is what is returned by this method.

SeaVipe

  • FireFly3 User
  • Junior Member
  • *
  • Posts: 129
  • Windows 10
Re: WinFBX - CFileSys Example typo
« Reply #4 on: September 05, 2018, 08:54:30 PM »

Much appreciated, thanks.
Logged
Clive Richey

SeaVipe

  • FireFly3 User
  • Junior Member
  • *
  • Posts: 129
  • Windows 10
Re: WinFBX - CFileSys
« Reply #5 on: September 06, 2018, 12:44:09 PM »

Hi Josť

Code: [Select]
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.
Logged
Clive Richey

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: WinFBX - CFileSys Example typo
« Reply #6 on: September 06, 2018, 03:04: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.

SeaVipe

  • FireFly3 User
  • Junior Member
  • *
  • Posts: 129
  • Windows 10
Re: WinFBX - CFileSys Example typo
« Reply #7 on: September 06, 2018, 03:21:31 PM »

That solved the crashing, thanks!
Logged
Clive Richey