“分组依据" Windows资源管理器中的某个文件夹 [英] "Group by" a certain folder in windows explorer
问题描述
我想做的是为我的应用程序创建一个文件夹,并确保每次用户输入此文件夹时,它都被分组,如下所示:
What I am trying to do is to crate a folder for my application, and to make sure each time a user enters this folder, it's grouped, like this:
除了将磁盘替换为某些文件夹/文件之外.
except that the disks would be replaced by some folders/files.
所以基本上,我试图实现分组依据"功能的作用:
so basically I'm trying to achieve exactly what "Group by" function does:
,我必须使用c/c ++代码或bat在我的应用程序中执行此操作.我猜想这需要在注册表中完成,但是我找不到位置.有什么主意吗?
and I have to do this in my application with c/c++ code or a bat. I'm guessing this needs to be done in the registry, but I cannot find where. any idea?
谢谢.
推荐答案
您必须了解,使用注册表更改资源管理器视图模式是很糟糕的事情.因此,由您自己承担风险.仅在WINDOWS 7上进行过测试.
You must understand that changing of Explorer view mode with registry is dirty hack. So USE ON YOUR OWN RISK. TESTED ON WINDOWS 7 ONLY.
procedure SetFolderGroupBy(AParentWnd: HWND; const AFolder: UnicodeString; const AColumn: TPropertyKey; AAscending: Boolean);
var
Desktop: IShellFolder;
Attr: DWORD;
Eaten: DWORD;
IDList: PItemIDList;
Bag: IPropertyBag;
Direction: DWORD;
begin
OleCheck(SHGetDesktopFolder(Desktop));
try
Attr := 0;
OleCheck(Desktop.ParseDisplayName(AParentWnd, nil, PWideChar(AFolder), Eaten, IDList, Attr));
try
OleCheck(SHGetViewStatePropertyBag(IDList, 'Shell', SHGVSPB_FOLDERNODEFAULTS, IPropertyBag, Bag));
try
OleCheck(Bag.Write('SniffedFolderType', 'Generic'));
finally
Bag := nil;
end;
OleCheck(SHGetViewStatePropertyBag_(IDList, 'Shell\{5C4F28B5-F869-4E84-8E60-F11DB97C5CC7}', SHGVSPB_FOLDERNODEFAULTS, IPropertyBag, Bag));
try
if AAscending then Direction := SORT_ASCENDING
else Direction := DWORD(SORT_DESCENDING);
OleCheck(Bag.Write('GroupByDirection', Direction));
OleCheck(Bag.Write('GroupByKey:FMTID', GUIDToString(AColumn.fmtid)));
OleCheck(Bag.Write('GroupByKey:PID', AColumn.pid));
OleCheck(Bag.Write('GroupView', DWORD(-1)));
finally
Bag := nil;
end;
finally
CoTaskMemFree(IDList);
end;
finally
Desktop := nil;
end;
end;
这篇关于“分组依据" Windows资源管理器中的某个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!