Passing COM Interface Implementation to PInvoke API Call,...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?=

    Passing COM Interface Implementation to PInvoke API Call,...

    Hi,

    i am looking for an example that shows how to
    implement a COM Interface (with events) and
    pass it to a Windows API Call via pointer. Since
    this is really new to me, i dont know where to
    start,...

    The Problem is still the EditSecurity Windows API
    call, that expects a pointer to a ISecurityInform ation
    Interface implementation as the second parameter.
    How to implement this Interface in C# and the
    how to pass this to the function,...?

    Any help is really welcome!

    Regards

    Kerem


    --
    -----------------------
    Beste Grüsse / Best regards / Votre bien devoue
    Kerem Gümrükcü
    Latest Project: http://www.codeplex.com/restarts
    Latest Open-Source Projects: http://entwicklung.junetz.de
    -----------------------
    "This reply is provided as is, without warranty express or implied."

  • Pavel Minaev

    #2
    Re: Passing COM Interface Implementation to PInvoke API Call,...

    On Sep 26, 9:19 pm, Kerem Gümrükcü <kareem...@hotm ail.comwrote:
    Hi,
    >
    i am looking for an example that shows how to
    implement a COM Interface (with events) and
    pass it to a Windows API Call via pointer. Since
    this is really new to me, i dont know where to
    start,...
    >
    The Problem is still the EditSecurity Windows API
    call, that expects a pointer to a ISecurityInform ation
    Interface implementation as the second parameter.
    How to implement this Interface in C# and the
    how to pass this to the function,...?
    If you have a typelib that defines the interface, you can use
    tlbimp.exe to produce a C# definition of that interface. Otherwise, my
    advice would be to do the same on a similar interface, then decompile
    the produced assembly using Reflector, and see how various COM
    constructs are translated to C#. From there, you should be able to
    hand-code the interface definition.

    To pass it in a P/Invoke call, nothing special is needed. You just
    declare the argument of a function with the type of that interface.

    Comment

    • =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?=

      #3
      Re: Passing COM Interface Implementation to PInvoke API Call,...

      Hi Pavel,

      i am very glad to get some reply here. I have never
      implemented a COM Interface in C# before, i mean
      handwritten. Can you point to some example or
      a documentation for this. There is no TypeLib
      available for that interface, just C++ and IDL Interface
      definitions in the Windows API Headers,...

      Regards

      Kerem

      --
      -----------------------
      Beste Grüsse / Best regards / Votre bien devoue
      Kerem Gümrükcü
      Latest Project: http://www.codeplex.com/restarts
      Latest Open-Source Projects: http://entwicklung.junetz.de
      -----------------------
      "This reply is provided as is, without warranty express or implied."
      "Pavel Minaev" <int19h@gmail.c omschrieb im Newsbeitrag
      news:5430018a-7ae2-4cb1-a22e-762e8261d871@59 g2000hsb.google groups.com...
      On Sep 26, 9:19 pm, Kerem Gümrükcü <kareem...@hotm ail.comwrote:
      Hi,
      >
      i am looking for an example that shows how to
      implement a COM Interface (with events) and
      pass it to a Windows API Call via pointer. Since
      this is really new to me, i dont know where to
      start,...
      >
      The Problem is still the EditSecurity Windows API
      call, that expects a pointer to a ISecurityInform ation
      Interface implementation as the second parameter.
      How to implement this Interface in C# and the
      how to pass this to the function,...?

      Comment

      • Pavel Minaev

        #4
        Re: Passing COM Interface Implementation to PInvoke API Call,...

        On Sep 29, 4:02 pm, Kerem Gümrükcü <kareem...@hotm ail.comwrote:
        i am very glad to get some reply here. I have never
        implemented a COM Interface in C# before, i mean
        handwritten. Can you point to some example or
        a documentation for this. There is no TypeLib
        available for that interface, just C++ and IDL Interface
        definitions in the Windows API Headers,...
        Here's an MSDN article explaining how to hand-write C# interface
        declarations for COM interfaces:

        Create wrappers of COM types manually. Use an existing IDL file or type library, or create managed declarations and export the assembly to a type library.

        Comment

        • =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?=

          #5
          Re: Passing COM Interface Implementation to PInvoke API Call,...

          Thanks for the Link Pavel,...


          Regards

          Kerem

          --
          -----------------------
          Beste Grüsse / Best regards / Votre bien devoue
          Kerem Gümrükcü
          Latest Project: http://www.codeplex.com/restarts
          Latest Open-Source Projects: http://entwicklung.junetz.de
          -----------------------
          "This reply is provided as is, without warranty express or implied."
          "Pavel Minaev" <int19h@gmail.c omschrieb im Newsbeitrag
          news:4a7f346f-8d46-409c-a6f9-dc2888dfe039@v5 3g2000hsa.googl egroups.com...
          On Sep 29, 4:02 pm, Kerem Gümrükcü <kareem...@hotm ail.comwrote:
          i am very glad to get some reply here. I have never
          implemented a COM Interface in C# before, i mean
          handwritten. Can you point to some example or
          a documentation for this. There is no TypeLib
          available for that interface, just C++ and IDL Interface
          definitions in the Windows API Headers,...
          Here's an MSDN article explaining how to hand-write C# interface
          declarations for COM interfaces:

          Create wrappers of COM types manually. Use an existing IDL file or type library, or create managed declarations and export the assembly to a type library.


          Comment

          Working...