incorrect declaration of SHGetFolderPath
Original Reporter info from Mantis: Enigma
-
Reporter name:
Original Reporter info from Mantis: Enigma
- Reporter name:
Description:
Due 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;
Mantis conversion info:
- Mantis ID: 17449
- OS: x64
- OS Build: Seven
- Platform: Windows
- Version: 2.4.3
- Fixed in version: 2.4.2
- Fixed in revision: 16247 (#807d2003)