Click here to Skip to main content
15,919,341 members
Home / Discussions / C#
   

C#

 
GeneralRe: making a microprocessor simulator in C# Pin
Djtech0115-Mar-10 4:57
Djtech0115-Mar-10 4:57 
QuestionAdvanced C# Question Pin
Dave Kerr15-Mar-10 1:19
mentorDave Kerr15-Mar-10 1:19 
AnswerRe: Advanced C# Question Pin
Richard MacCutchan15-Mar-10 1:34
mveRichard MacCutchan15-Mar-10 1:34 
AnswerRe: Advanced C# Question Pin
Mirko198015-Mar-10 1:50
Mirko198015-Mar-10 1:50 
GeneralRe: Advanced C# Question Pin
ThatsAlok15-Mar-10 1:55
ThatsAlok15-Mar-10 1:55 
GeneralRe: Advanced C# Question Pin
Mirko198015-Mar-10 2:05
Mirko198015-Mar-10 2:05 
GeneralRe: Advanced C# Question Pin
Dave Kerr15-Mar-10 2:26
mentorDave Kerr15-Mar-10 2:26 
GeneralRe: Advanced C# Question Pin
Pete O'Hanlon15-Mar-10 5:44
mvePete O'Hanlon15-Mar-10 5:44 
DaveKerr wrote:
so as I understand it, I can use Activator.CreateInstance to get the COM object, but I cannot use reflection


You can, as long as the component supports IDispatch you can use the CustomMarshaller assembly (you'll commonly find it in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727). The following code sample displays the members of DirControl.DirList.8.0 using reflection:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.CustomMarshalers;
using System.Reflection;

namespace ComMarshaller
{
  [
  ComImport,
  Guid("00020400-0000-0000-C000-000000000046"),
  InterfaceType(ComInterfaceType.InterfaceIsIUnknown)
  ]
  public interface IDispatch
  {
    void Reserved();
    [PreserveSig]
    int GetTypeInfo(uint nInfo, int lcid,
    [MarshalAs(
    UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(TypeToTypeInfoMarshaler))]
    out Type typeInfo);
  }

  class Program
  {
    static void Main(string[] args)
    {
      Type type = Type.GetTypeFromProgID("DirControl.DirList.8.0");
      object o = Activator.CreateInstance(type);
      IDispatch disp = o as IDispatch;
      if (disp != null)
      {
        Type tp = null;
        disp.GetTypeInfo(0, 0, out tp);
        MemberInfo[] mi = tp.GetMembers();

        foreach (MemberInfo minfo in mi)
        {
          Console.WriteLine(minfo.Name);
        }
      }

      Console.WriteLine("Done");
      Console.ReadKey();
    }
  }
}
Remember, this needs CustomMarshaller.dll added as a reference in your application.

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



GeneralRe: Advanced C# Question Pin
ThatsAlok15-Mar-10 4:02
ThatsAlok15-Mar-10 4:02 
QuestionWindows Explorer shell context menu Pin
shah zad14-Mar-10 23:40
shah zad14-Mar-10 23:40 
Questionhow to convert Microsoft.Office.Interop.Excel.range to a dataset Pin
neodeaths14-Mar-10 23:30
neodeaths14-Mar-10 23:30 
AnswerRe: how to convert Microsoft.Office.Interop.Excel.range to a dataset Pin
Gaurav Dudeja India14-Mar-10 23:40
Gaurav Dudeja India14-Mar-10 23:40 
QuestionClipboard doesn't get image after Ctrl-C is pressed Pin
highton14-Mar-10 22:15
highton14-Mar-10 22:15 
AnswerRe: Clipboard doesn't get image after Ctrl-C is pressed Pin
AspDotNetDev14-Mar-10 22:25
protectorAspDotNetDev14-Mar-10 22:25 
GeneralRe: Clipboard doesn't get image after Ctrl-C is pressed Pin
highton14-Mar-10 22:43
highton14-Mar-10 22:43 
GeneralRe: Clipboard doesn't get image after Ctrl-C is pressed Pin
OriginalGriff14-Mar-10 22:55
mveOriginalGriff14-Mar-10 22:55 
GeneralRe: Clipboard doesn't get image after Ctrl-C is pressed Pin
AspDotNetDev14-Mar-10 23:52
protectorAspDotNetDev14-Mar-10 23:52 
GeneralRe: Clipboard doesn't get image after Ctrl-C is pressed Pin
Dave Kreskowiak15-Mar-10 4:16
mveDave Kreskowiak15-Mar-10 4:16 
AnswerRe: Clipboard doesn't get image after Ctrl-C is pressed Pin
Luc Pattyn15-Mar-10 1:51
sitebuilderLuc Pattyn15-Mar-10 1:51 
QuestionHow to convert image files to PDF files Pin
NarVish14-Mar-10 21:59
NarVish14-Mar-10 21:59 
AnswerRe: How to convert image files to PDF files Pin
ScottM114-Mar-10 22:50
ScottM114-Mar-10 22:50 
GeneralRe: How to convert image files to PDF files Pin
NarVish14-Mar-10 23:22
NarVish14-Mar-10 23:22 
GeneralMessage Closed Pin
14-Mar-10 23:33
stancrm14-Mar-10 23:33 
GeneralRe: How to convert image files to PDF files Pin
NarVish14-Mar-10 23:48
NarVish14-Mar-10 23:48 
GeneralRe: How to convert image files to PDF files Pin
ThatsAlok15-Mar-10 1:58
ThatsAlok15-Mar-10 1:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.