8

次のコードを使用してシェル dll を参照しています

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

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


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

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

私はC# の助けを借りました: Windows シェル インターフェイスを参照していますが、うまくいきませんでした。

Interop.Shell32 dll である Microsoft Shell Controls および Automation リファレンスを使用してシェルを参照しています

誰かがそれを導くことができれば、それは本当に役に立ちます。

4

3 に答える 3

19

わかりました、これが誰かを助けるために問題を解決した方法です

これは私の新しいコードがどのように見えるかです

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

}

このスクリプトは、 http://nerdynotes.blogspot.com/2008/06/vbnet-shell32-code-compiled-on-vista.htmlのヘルプを組み合わせたものです。

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

2 番目のリンクはスペイン語ですが、Google 翻訳を使用して英語で作成しました。

この質問に答えてくれたすべての人に感謝します

于 2012-08-22T16:22:44.470 に答える
1

これを見てください: http://nerdynotes.blogspot.com/2008/06/vbnet-shell32-code-compiled-on-vista.html同じ問題だと思います。

于 2012-08-22T14:27:02.603 に答える