reference a windows shell interface using .net 4.0

前端 未结 3 595
情深已故
情深已故 2020-12-11 16:54

I am using the following code to reference a shell dll

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

            Shell s = (Shell)Acti         


        
3条回答
  •  悲哀的现实
    2020-12-11 17:22

    Instead of

    Type t = Type.GetTypeFromProgID("Shell.Application");
    
    dynamic shell = Activator.CreateInstance(t);
    

    I used

    var shell = (IShellDispatch4) new Shell();
    

    shell.Namespace then works as expected.

    Turns out that reference for a shell object defaults to IShellDispatch5, which can't be used in XP or 2003.

提交回复
热议问题