前一个问题,有一个解释如何隐藏桌面项目:隐藏桌面项目 - 不工作
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的新任务。) –