参考使用.NET 4.0 Windows Shell界面 [英] reference a windows shell interface using .net 4.0

查看:311
本文介绍了参考使用.NET 4.0 Windows Shell界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码来引用一个shell DLL

I am using the following code to reference a shell dll

            Type t = Type.GetTypeFromProgID("Shell.Application");

            Shell s = (Shell)Activator.CreateInstance(t);


            Console.WriteLine("success");
            Console.ReadLine();



它正常工作在我的Windows当我尝试运行赢2003服务器上的EXE 7开发machine.But我得到这个例外

It works fine on my windows 7 development machine.But when I try running the exe on Win 2003 server I get this exception

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)).



我从的 C#:引用Windows Shell界面但没有运气

我使用微软引用外壳壳牌控制和自动化的参考是Interop.Shell32 DLL

I am referencing shell using Microsoft Shell Controls and Automation reference which is Interop.Shell32 dll

如果有人能够引导它真的会有所帮助。

If someone can guide it will really helpful.

推荐答案

我通过这个问题好了,这是怎么了柜面它可以帮助别人

Ok,this is how I got through the problem incase it helps someone

这是我的新代码看起来像

This is how my new code looks like

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);

}

该脚本是由
合并帮助< A HREF =htt​​p://nerdynotes.blogspot.com/2008/06/vbnet-shell32-code-compiled-on-vista.html> http://nerdynotes.blogspot.com/2008/06/vbnet-shell32 -code编译-ON-vista.html

http://foro.h-sec.org/net/problemas-en-net/

第二个环节是在西班牙,我用谷歌翻译,以弥补在英语

The second link is in spanish,I used google translate to make it up in English

感谢所有谁回答这个问题

Thanks to all who replied to this question

这篇关于参考使用.NET 4.0 Windows Shell界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆