use*_*926 8 c# windows-shell c#-4.0
我使用以下代码来引用shell DLL
Type t = Type.GetTypeFromProgID("Shell.Application");
Shell s = (Shell)Activator.CreateInstance(t);
Console.WriteLine("success");
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
它在我的Windows 7开发机器上工作正常.但是当我尝试在Win 2003服务器上运行exe时,我得到了这个异常
Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell3
2.Shell'. This operation failed because the QueryInterface call on the COM compo
nent for the interface with IID '{866738B9-6CF2-4DE8-8767-F794EBE74F4E}' failed
due to the following error: No such interface supported (Exception from HRESULT:
0x80004002 (E_NOINTERFACE)).
Run Code Online (Sandbox Code Playgroud)
我从C#中获得了一些帮助:引用了一个Windows shell界面,但没有运气.
我使用Microsoft Shell控件和自动化引用引用shell,这是Interop.Shell32 dll
如果有人可以指导,那将非常有帮助.
use*_*926 17
好吧,这就是我解决问题的方法,因为它可以帮助某人
这就是我的新代码的样子
Type t = Type.GetTypeFromProgID("Shell.Application");
dynamic shell = Activator.CreateInstance(t);
//This is browse through all the items in the folder
var objFolder = shell.NameSpace(@"\\fileshares\Files\test");
foreach (var item in objFolder.Items())
{
//This is to get the file's comments for each files in the folderitem
string file_version = objFolder.GetDetailsOf(item, 14).ToString();
Console.WriteLine(file_version);
}
Run Code Online (Sandbox Code Playgroud)
这个脚本是通过http://nerdynotes.blogspot.com/2008/06/vbnet-shell32-code-compiled-on-vista.html的帮助结合起来的.
和
http://foro.h-sec.org/net/problemas-en-net/
第二个链接是西班牙语,我使用谷歌翻译用英语补充
感谢所有回复此问题的人