Recent

Author Topic: shlobj.pp SHGetSetFolderCustomSettingsA and W problem  (Read 249 times)

440bx

  • Hero Member
  • *****
  • Posts: 5896
shlobj.pp SHGetSetFolderCustomSettingsA and W problem
« on: September 13, 2025, 10:26:24 pm »
Hello,

the file shlobj.pp has the following definitions:
Code: Pascal  [Select][+][-]
  1.   function SHGetSetFolderCustomSettingsA(pfcs:LPSHFOLDERCUSTOMSETTINGSA; pszPath:lpcstr; dwReadWrite:DWord):HRESULT;StdCall;external External_library name 'SHGetSetFolderCustomSettingsA';
  2.   function SHGetSetFolderCustomSettingsW(pfcs:LPSHFOLDERCUSTOMSETTINGSW; pszPath:lpcwstr; dwReadWrite:DWord):HRESULT;StdCall;external External_library name 'SHGetSetFolderCustomSettingsW';
  3.   {$ifdef unicode}
  4.   function SHGetSetFolderCustomSettings (pfcs:LPSHFOLDERCUSTOMSETTINGSW; pszPath:lpcwstr; dwReadWrite:DWord):HRESULT;StdCall;external External_library name 'SHGetSetFolderCustomSettingsW';
  5.   {$else}
  6.   function SHGetSetFolderCustomSettings (pfcs:LPSHFOLDERCUSTOMSETTINGSA; pszPath:lpcstr; dwReadWrite:DWord):HRESULT;StdCall;external External_library name 'SHGetSetFolderCustomSettingsA';
  7.   {$endif}
  8.  
Those definitions are correct for Windows XP.

I do _not_ know if they are correct for Windows Vista.

They are _incorrect_ for all versions of Windows starting with Win 7 because neither the "A" nor the "W" entry point exist.  Beginning in Win 7, there is a single entry point named SHGetSetFolderCustomSettings (note there is no A nor W) and, that entry point uses widechar.

The problem with the current definition occurs when unicode is not defined.  In that case, the resulting definition takes a pchar instead of a pwidechar.

The same problem exists with the LPSHFOLDERCUSTOMSETTINGS structure, beginning with Win 7, there is no A and W versions only a plain LPSHFOLDERCUSTOMSETTINGS which uses wide characters.  The non-unicode definition will have an incorrect (and non-existent) parameter type.

HTH.


FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018