显然这对于win32 api来说是微不足道的 – CreateDirectory()。 但是我正在尝试托pipe一个IShellView,并且希望以最基于shell的方式来实现这一点。 我原以为会有一个createobject或者createfolder或者一些来自于一个IShellFolder的文件夹。 但是IShellView,IShellFolder,甚至IFolderView都没有这样的东西。
有没有一种Shell编程的方式来创build一个新的文件夹? 还是我需要用老式的path名创build一个文件夹?
如果必须通过CreateDirectory()来完成,那么我的下一个问题可能是:如何让IShellView / IFolderView实际看到这个新对象并将其显示给用户?
动机:创build我自己的文件对话框replace,我想提供标准XP风格文件对话框的“新文件夹”工具栏图标function。
Windows将总是允许钩子和/或日志logging?
从用户模式访问Windows Native API
Linux,了解setsockopt()PACKET_FANOUTnetworking缩放
你如何将unit testing引入一个大的,传统的(C / C ++)代码库?
编辑:我继续创build一些基本上可以使用CreateDirectory的东西。 但是,我仍然希望有一个更好的方法来做到这一点,但是这样你就可以看到如何工作,并提供更好的想法来解决这个问题:
PidlUtils::Pidl pidl(m_folder); CFilename folderName(GetdisplayNameOf(pidl),"New Folder"); for (int i = 2; folderName.Exists(); ++i) folderName.SetFullName(FString("New Folder (%d)",i)); if (!CPathname::Create(folderName,false)) throw CContextException("Unable to create a new folder here: "); // get the PIDL for the newly created folder PidlUtils::Pidl pidlNew; #ifdef UNICODE const wchar_t * wszName = folderName.c_str(); #else wchar_t wszName[MAX_PATH]; MultiBytetoWideChar(CP_ACP,folderName.GetFullName(),-1,wszName,MAX_PATH); #endif m_hresult = m_folder->ParsedisplayName(NULL,NULL,pidlNew,NULL); if (Failed(m_hresult)) throw CLabeledException(FString("Unable to get the PIDL for the new folder: 0x%X",m_hresult)); // upgrade our interface so we can select & rename it CComQIPtr<IShellView2> sv2(m_shell_view); if (!sv2) throw CLabeledException("Unable to obtain the IShellView2 we need to rename the newly created folder."); // force it to see thew new folder sv2->Refresh(); // select the new folder,and begin the rename process m_hresult = sv2->SelectAndPositionItem(pidlNew,SVSI_EDIT|SVSI_deselectOTHERS|SVSI_ENSUREVISIBLE|SVSI_POSITIONITEM,NULL); if (Failed(m_hresult)) throw CLabeledException(FString("Unable to select and position the new folder item: 0x%X",m_hresult));
LINUX到Windows不好的编码响应
在C ++中,如何让用户在应用程序窗口中指定屏幕上的一个点(X,Y)?
从浏览器启动一个exe(Windows)
备用程序“less”的Linux命令/使“less”安全
减lessprimefaces计数器 – 但<只>在一个条件下
Shell文件夹通常实现IStorage接口,所以这非常简单。 例如,下面在桌面上创建一个名为“abcd”的文件夹:
CComPtr <IShellFolder> pDesktop;
HRESULT hr = SHGetDesktopFolder(&pDesktop);
如果(Failed(hr))返回;
CComQIPtr <IStorage> pStorage(pDesktop);
如果(!pStorage)返回;
CComPtr <IStorage> dummy;
hr = pStorage-> CreateStorage(L“abcd”,STGM_FAILIFTHERE,0,0,&dummy);
是的,你可以得到IContextMenu并寻找子菜单,但是为什么打扰,只要调用CreateDirectory后调用SHChangeNotify
Win32 API函数CreateDirectory似乎是“正确的方法”。 至少,我可以找到更好的东西 – 这里的答案并没有为更好的方式提供任何帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。