View Issue Details

IDProjectCategoryView StatusLast Update
0017449FPCCompilerpublic2011-05-01 18:33
ReporterEnigma Assigned ToMarco van de Voort  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOSx64 
Product Version2.4.3 
Fixed in Version2.4.2 
Summary0017449: incorrect declaration of SHGetFolderPath
DescriptionDue to incorrect declaration of function SHGetFolderPath, it sometimes fails to return folder.

The problem appears due to incorrect type of the second parameter. This declaration is from MS site, second parameters is int.
HRESULT SHGetFolderPath(
  __in HWND hwndOwner,
  __in int nFolder,
  __in HANDLE hToken,
  __in DWORD dwFlags,
  __out LPTSTR pszPath
);
But in free pascal it's type is WORD.

So, when the program is compiled, the assembler listing of passing of second parameter shoud look like:
mov edx, SECOND_PARAMETER

but free pascal generates:
mov dx, SECOND_PARAMETER

In the first correct example, the high dword in rdx clears, but in the second - high dword of rdx keeps unclear, and the function sometimes gets the second parameter with the value more than maximum of integer and function fails.

To solve problem need just redeclare type of second parameter from WORD to Integer or Dword;
TagsNo tags attached.
Fixed in Revision16247
FPCOldBugId0
FPCTarget
Attached Files

Activities

Marco van de Voort

2010-09-20 19:54

manager   ~0041239

Fixed. (shfolder.pp). Note that the normal, Delphi compatible unit for this is shlobj.pp, and there it is right.

If this unit has no dependancy problem (I created it after I stopped testing on w9x), you can use it as workaround

Marco van de Voort

2011-05-01 18:33

manager   ~0047952

As far as I know a last minute merge to 2.4.2

Issue History

Date Modified Username Field Change
2010-09-20 13:24 Enigma New Issue
2010-09-20 19:54 Marco van de Voort Fixed in Revision => 16032
2010-09-20 19:54 Marco van de Voort Status new => resolved
2010-09-20 19:54 Marco van de Voort Resolution open => fixed
2010-09-20 19:54 Marco van de Voort Assigned To => Marco van de Voort
2010-09-20 19:54 Marco van de Voort Note Added: 0041239
2011-05-01 15:56 Marco van de Voort FPCOldBugId => 0
2011-05-01 15:56 Marco van de Voort Fixed in Version => 2.4.2
2011-05-01 18:33 Marco van de Voort Fixed in Revision 16032 => 16247
2011-05-01 18:33 Marco van de Voort Note Added: 0047952
2011-05-01 18:33 Marco van de Voort Status resolved => closed