1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
unit ShellAdv;
//******************************************************************************
//*** Change le setting d'affichage des fichiers cachée de windows explorer
//*** Eric Boisvert
//***
//*** inspiré du code ici
//*** http://www.delphipraxis.net/topic62087,0,asc,0.html
//***
interface
uses windows,Messages,ShlObj;
type
SHELLSTATE = packed record
Flags1: DWORD;
(*
BOOL fShowAllObjects : 1;
BOOL fShowExtensions : 1;
BOOL fNoConfirmRecycle : 1;
BOOL fShowSysFiles : 1;
BOOL fShowCompColor : 1;
BOOL fDoubleClickInWebView : 1;
BOOL fDesktopHTML : 1;
BOOL fWin95Classic : 1;
BOOL fDontPrettyPath : 1;
BOOL fShowAttribCol : 1; // No longer used, dead bit
BOOL fMapNetDrvBtn : 1;
BOOL fShowInfoTip : 1;
BOOL fHideIcons : 1;
BOOL fWebView : 1;
BOOL fFilter : 1;
BOOL fShowSuperHidden : 1;
BOOL fNoNetCrawling : 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
Flags2: DWORD;
(*
BOOL fSepProcess: 1;
// new for Whistler.
BOOL fStartPanelOn: 1; //Indicates if the Whistler StartPanel mode is ON or OFF.
BOOL fShowStartPage: 1; //Indicates if the Whistler StartPage on desktop is ON or OFF.
UINT fSpareFlags : 13;
*)
end;
LPSHELLSTATE = ^SHELLSTATE;
const
SSF_SHOWALLOBJECTS = $00000001;
SSF_SHOWEXTENSIONS = $00000002;
SSF_HIDDENFILEEXTS = $00000004;
SSF_SERVERADMINUI = $00000004;
SSF_SHOWCOMPCOLOR = $00000008;
SSF_SORTCOLUMNS = $00000010;
SSF_SHOWSYSFILES = $00000020;
SSF_DOUBLECLICKINWEBVIEW = $00000080;
SSF_SHOWATTRIBCOL = $00000100;
SSF_DESKTOPHTML = $00000200;
SSF_WIN95CLASSIC = $00000400;
SSF_DONTPRETTYPATH = $00000800;
SSF_SHOWINFOTIP = $00002000;
SSF_MAPNETDRVBUTTON = $00001000;
SSF_NOCONFIRMRECYCLE = $00008000;
SSF_HIDEICONS = $00004000;
SSF_FILTER = $00010000;
SSF_WEBVIEW = $00020000;
SSF_SHOWSUPERHIDDEN = $00040000;
SSF_SEPPROCESS = $00080000;
SSF_NONETCRAWLING = $00100000;
SSF_STARTPANELON = $00200000;
SSF_SHOWSTARTPAGE = $00400000;
procedure SHShowHiddenFile(show: Boolean);
function ShGetShowHiddenFileState():boolean;
implementation
procedure SHGetSetSettings(var lpss: SHELLSTATE;
dwMask: DWORD; bSet: BOOL) stdcall;
external 'shell32.dll' index 68;
//==============================================================================
//== Lecture de l'etat actuelle de explorer
//== Pour savoir si on affiche ou non les fichiers cachés
//==============================================================================
function ShGetShowHiddenFileState():boolean;
var
lpss: SHELLSTATE;
bShowAll: Boolean;
begin
ZeroMemory(@lpss, sizeof(lpss));
// Retrieve current state
SHGetSetSettings(lpss, SSF_SHOWALLOBJECTS, False);
// Return the current style
result:= (lpss.Flags1 and SSF_SHOWALLOBJECTS) = SSF_SHOWALLOBJECTS;
end;
//==============================================================================
//== Changement pour que explorer affiche ou non les fichiers cachés
//==============================================================================
procedure SHShowHiddenFile(show: Boolean);
var
lpss: SHELLSTATE;
bShowAll: Boolean;
begin
ZeroMemory(@lpss, sizeof(lpss));
// Retrieve current state
SHGetSetSettings(lpss, SSF_SHOWALLOBJECTS, False);
// Check the current style
bShowAll := (lpss.Flags1 and SSF_SHOWALLOBJECTS) = SSF_SHOWALLOBJECTS;
// If a change occurred
if (bShowAll <> show) then
begin
if (Show) then
lpss.Flags1 := 1
else
lpss.Flags1 :=0;
// Set new state
SHGetSetSettings(lpss, SSF_SHOWALLOBJECTS, True);
// Notify explorer that something as change
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
end;
end;
end. |