[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

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

Kerem G?mr?kc?

9/26/2008 5:19:00 PM

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 ISecurityInformation
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.co...
Latest Open-Source Projects: http://entwicklung...
-----------------------
"This reply is provided as is, without warranty express or implied."

4 Answers

Pavel Minaev

9/29/2008 7:12:00 AM

0

On Sep 26, 9:19 pm, Kerem Gümrükcü <kareem...@hotmail.com> wrote:
> 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 ISecurityInformation
> 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.

Kerem G?mr?kc?

9/29/2008 12:03:00 PM

0

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.co...
Latest Open-Source Projects: http://entwicklung...
-----------------------
"This reply is provided as is, without warranty express or implied."
"Pavel Minaev" <int19h@gmail.com> schrieb im Newsbeitrag
news:5430018a-7ae2-4cb1-a22e-762e8261d871@59g2000hsb.googlegroups.com...
On Sep 26, 9:19 pm, Kerem Gümrükcü <kareem...@hotmail.com> wrote:
> 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 ISecurityInformation
> Interface implementation as the second parameter.
> How to implement this Interface in C# and the
> how to pass this to the function,...?

Pavel Minaev

10/1/2008 10:07:00 AM

0

On Sep 29, 4:02 pm, Kerem Gümrükcü <kareem...@hotmail.com> wrote:
> 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:

http://msdn.microsoft.com/en-us/library/x8f...

Kerem G?mr?kc?

10/2/2008 3:11:00 AM

0

Thanks for the Link Pavel,...


Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.co...
Latest Open-Source Projects: http://entwicklung...
-----------------------
"This reply is provided as is, without warranty express or implied."
"Pavel Minaev" <int19h@gmail.com> schrieb im Newsbeitrag
news:4a7f346f-8d46-409c-a6f9-dc2888dfe039@v53g2000hsa.googlegroups.com...
On Sep 29, 4:02 pm, Kerem Gümrükcü <kareem...@hotmail.com> wrote:
> 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:

http://msdn.microsoft.com/en-us/library/x8f...