本文介绍了参考使用.NET 4.0 Windows Shell界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我使用下面的代码来引用一个shell DLLI 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 exceptionUnable to cast COM object of type 'System.__ComObject' to interface type 'Shell32.Shell'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{866738B9-6CF2-4DE8-8767-F794EBE74F4E}' faileddue to the following error: No such interface supported (Exception from HRESULT:0x80004002 (E_NOINTERFACE)). 我从的 C#:引用Windows Shell界面但没有运气我使用微软引用外壳壳牌控制和自动化的参考是Interop.Shell32 DLLI 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 likeType t = Type.GetTypeFromProgID("Shell.Application");dynamic shell = Activator.CreateInstance(t);//This is browse through all the items in the foldervar 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);}该脚本是由合并帮助 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界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-07 01:56