前一個問題,有一個解釋如何隱藏桌面項目:隱藏桌面項目 - 不工作
How to hide desktop icons programatically?
出於某種原因,這個代碼不爲我工作。
我會簡單地評論上面的鏈接,但我沒有足夠的權限對別人的問題發表評論......
任何想法是怎麼回事?桌面根本不隱藏。
更新:另外,我嘗試使用下面的代碼(如建議here),但仍然沒有效果:
struct SHELLSTATE
{
bool fShowAllObjects;
bool fShowExtensions;
bool fNoConfirmRecycle;
bool fShowSysFiles;
bool fShowCompColor;
bool fDoubleClickInWebView;
bool fDesktopHTML;
bool fWin95Classic;
bool fDontPrettyPath;
bool fShowAttribCol;
bool fMapNetDrvBtn;
bool fShowInfoTip1;
bool fHideIcons1;
bool fWebView1;
bool fFilter1;
bool fShowSuperHidden1;
bool fNoNetCrawling1;
UInt32 dwWin95Unused;
uint uWin95Unused;
long lParamSort;
int iSortDirection;
uint version;
uint uNotUsed;
bool fSepProcess;
bool fStartPanelOn;
bool fShowStartPage;
bool fAutoCheckSelect;
bool fIconsOnly;
bool fShowTypeOverlay;
uint fSpareFlags;
}
class MyClass
{
const UInt32 SSF_HIDEICONS = 0x00004000;
[DllImport("Shell32.dll")]
static extern void SHGetSetSettings(ref SHELLSTATE state, UInt32 dwMask, bool bSet);
static void Foobar()
{
SHELLSTATE stateOfMind = new SHELLSTATE();
Console.WriteLine("Set to true:");
SHGetSetSettings(ref stateOfMind, SSF_HIDEICONS, true);
Console.ReadKey();
Console.WriteLine("Set to false:");
SHGetSetSettings(ref stateOfMind, SSF_HIDEICONAS, false);
Console.ReadKey();
}
}
你嘗試重新啓動Explorer.exe的* *,例如*提筆*評論? – Otiel
這個答案是一個嚴重的問題。我並不感到驚訝,它不起作用。您是否使用IShellFolder尋找基於shell API的方法? –
@Otiel,我試了一下。 (也就是說,我結束了explorer.exe並開始了一個名爲explorer的新任務。) –