PC Review


Reply
Thread Tools Rate Thread

__cdecl callback function with P/Invoke

 
 
pawel
Guest
Posts: n/a
 
      16th Jan 2004
Hi!
I have a .dll library, with some exported function, which looks something
like this:

extern "C" {
int exported_f (int (__cdecl *callback) (int a, int b)) ;
}

now, I want to invoke this function wihtin the managed code and supply my
managed delegate function poiter as callback. I use DllImport, we know how
to do this
The problem is that: when the function pointer parameter in exported
function is __stdcall, everythig works just fine. But how can I use
delegates for __cdecl callback function pointers ?..
I found CallingConventions, but this is only valid for imported function
itself, not for its parameters (
Please, help me ! (sorry for my poor english

--
Pawel



 
Reply With Quote
 
 
 
 
Chris Taylor
Guest
Posts: n/a
 
      17th Jan 2004
Hi,

You can not do this in C#/VB.NET. An option might be to write a MC++ wrapper
for the library function and then let the MC++ callback call to your
delegate.

Hope this helps
--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
"pawel" <(E-Mail Removed)> wrote in message
news:%23zWd8$(E-Mail Removed)...
> Hi!
> I have a .dll library, with some exported function, which looks something
> like this:
>
> extern "C" {
> int exported_f (int (__cdecl *callback) (int a, int b)) ;
> }
>
> now, I want to invoke this function wihtin the managed code and supply my
> managed delegate function poiter as callback. I use DllImport, we know how
> to do this
> The problem is that: when the function pointer parameter in exported
> function is __stdcall, everythig works just fine. But how can I use
> delegates for __cdecl callback function pointers ?..
> I found CallingConventions, but this is only valid for imported function
> itself, not for its parameters (
> Please, help me ! (sorry for my poor english
>
> --
> Pawel
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CallBack Function In Win API =?Utf-8?B?UWluZ2RvbmcgWi4=?= Microsoft VB .NET 0 14th Jun 2006 12:09 AM
Using callback function =?Utf-8?B?U2l2YXJhbWFuLlM=?= Microsoft ASP .NET 6 7th Aug 2005 11:07 AM
does .Net framework1.1 support P/Invoke callback functoin? =?Utf-8?B?Z2luZWU=?= Microsoft Dot NET Compact Framework 3 25th Mar 2005 11:44 AM
P/Invoke & CallBack functions Maxim Kazitov Microsoft C# .NET 1 31st Mar 2004 10:31 PM
__cdecl callback function with P/Invoke pawel Microsoft Dot NET 1 17th Jan 2004 09:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:18 PM.