I just read this question and this question, and since then I have been trying to call SHGetSetSettings in Delphi. This is a function of shell32.dll
, but is not
The D2010 declaration of SHELLSTATE in ShlObj.pas is unfortunately incorrect, but the first group of bits (17) is correctly matched with Data: DWORD;
(Yours is indeed OK).
There could be 18 or 19 of them all the same. Then we should get 2 more DWORD/UINT for the 2 Win95unused, not only Data2.
Too bad because the SSF flags and SHGetSetSettings declarations are already done in there and correct.
The correct declaration according to MSDN should be IMO:
tagSHELLSTATEW = record
Data: DWORD;
{ fShowAllObjects: BOOL:1;
fShowExtensions: BOOL:1;
fNoConfirmRecycle: BOOL:1;
fShowSysFiles: BOOL:1;
fShowCompColor: BOOL:1;
fDoubleClickInWebView: BOOL:1;
fDesktopHTML: BOOL:1;
fWin95Classic: BOOL:1;
fDontPrettyPath: BOOL:1;
fShowAttribCol: BOOL:1;
fMapNetDrvBtn: BOOL:1;
fShowInfoTip: BOOL:1;
fHideIcons: BOOL:1;
fWebView: BOOL:1;
fFilter: BOOL:1;
fShowSuperHidden: BOOL:1;
fNoNetCrawling: BOOL:1;}
dwWin95Unused: DWORD;// Win95 only - no longer supported pszHiddenFileExts
uWin95Unused: UINT; // Win95 only - no longer supported cbHiddenFileExts
// Note: Not a typo! This is a persisted structure so we cannot use LPARAM
lParamSort: Integer;
iSortDirection: Integer;
version: UINT;
// new for win2k. need notUsed var to calc the right size of ie4 struct
// FIELD_OFFSET does not work on bit fields
uNotUsed: UINT;// feel free to rename and use}
Data2: DWORD;
{ fSepProcess: BOOL:1;
// new for Whistler.
fStartPanelOn: BOOL:1;
fShowStartPage: BOOL:1;
// new for Windows Vista
fAutoCheckSelect: BOOL:1;
fIconsOnly: BOOL:1;
fShowTypeOverlay: BOOL:1;
// If you need a new flag, steal a bit from from fSpareFlags.
// Also, keep SHELLFLAGSTATE and SHGetSettings in sync when adding new flags.
fSpareFlag: UINT:13;}
end;
You can verify that this allows to get the sorting properties correctly with:
var
lpss: tagSHELLSTATEW;
begin
ZeroMemory(@lpss, SizeOf(lpss));
SHGetSetSettings(lpss, SSF_SORTCOLUMNS, False);