473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

delegate calling convention

apm
Is there a way to change the calling convention of a delegate to Cdecl? Is
it possible to define a callback function in C# that used the Cdecl
convention?

Thanks in advance.
Nov 17 '05 #1
4 4781
apm,

You can only do this in .NET 2.0. You can apply the
UnmanagedFunctionPointer attribute to the delegate.

In .NET 1.1 and before, you would have to pass your delegate to an
unmanaged piece of code which has the signature of the delegate, and pass
that to your function.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"apm" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:wCgUe.3641$nq.3584@lakeread05...
Is there a way to change the calling convention of a delegate to Cdecl?
Is it possible to define a callback function in C# that used the Cdecl
convention?

Thanks in advance.

Nov 17 '05 #2
apm

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eN**************@TK2MSFTNGP14.phx.gbl...
apm,

You can only do this in .NET 2.0. You can apply the
UnmanagedFunctionPointer attribute to the delegate.

In .NET 1.1 and before, you would have to pass your delegate to an
unmanaged piece of code which has the signature of the delegate, and pass
that to your function.

Hope this helps.
Thank you. This is what I have done in the past using C++. Can it be done
with C#?


--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"apm" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:wCgUe.3641$nq.3584@lakeread05...
Is there a way to change the calling convention of a delegate to Cdecl?
Is it possible to define a callback function in C# that used the Cdecl
convention?

Thanks in advance.


Nov 17 '05 #3
No, not in v1.x. All you can do is change your C++ code's calling convention
to _stdcall (WINAPI), which is the default for callbacks in Win32. Another
option is to change and reassemble the IL in a post-build step.

Willy.
"apm" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:u7kUe.3653$nq.1829@lakeread05...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:eN**************@TK2MSFTNGP14.phx.gbl...
apm,

You can only do this in .NET 2.0. You can apply the
UnmanagedFunctionPointer attribute to the delegate.

In .NET 1.1 and before, you would have to pass your delegate to an
unmanaged piece of code which has the signature of the delegate, and pass
that to your function.

Hope this helps.


Thank you. This is what I have done in the past using C++. Can it be
done with C#?


--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"apm" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:wCgUe.3641$nq.3584@lakeread05...
Is there a way to change the calling convention of a delegate to Cdecl?
Is it possible to define a callback function in C# that used the Cdecl
convention?

Thanks in advance.



Nov 17 '05 #4
apm

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OL**************@TK2MSFTNGP14.phx.gbl...
No, not in v1.x. All you can do is change your C++ code's calling
convention to _stdcall (WINAPI), which is the default for callbacks in
Win32.
I don't have the source.
Another option is to change and reassemble the IL in a post-build step.
Interesting.

Willy.
Thank you so much.


"apm" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:u7kUe.3653$nq.1829@lakeread05...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:eN**************@TK2MSFTNGP14.phx.gbl...
apm,

You can only do this in .NET 2.0. You can apply the
UnmanagedFunctionPointer attribute to the delegate.

In .NET 1.1 and before, you would have to pass your delegate to an
unmanaged piece of code which has the signature of the delegate, and
pass that to your function.

Hope this helps.


Thank you. This is what I have done in the past using C++. Can it be
done with C#?


--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"apm" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:wCgUe.3641$nq.3584@lakeread05...
Is there a way to change the calling convention of a delegate to Cdecl?
Is it possible to define a callback function in C# that used the Cdecl
convention?

Thanks in advance.



Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
11
by: Yoni Rabinovitch | last post by:
Is it possible to invoke a C# delegate/event handler asynchronously, from unmanaged C++ ? I assume this requires a Managed C++ wrapper, which would call BeginInvoke on the delegate ? Is this...
3
by: Todd Schinell | last post by:
Back in July, Jeffery Tan posted this: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OWOTdf0VDHA.2296%40cpmsftngxa06.phx.gbl In response as to how to get click events from a...
1
by: Alexander Arlievsky | last post by:
Hi, I have mixed mode dll, which contains files with managed objects written in MC++, and files with regular "C" functions. One of those functions receives function pointer as parameter. I want to...
3
by: apm | last post by:
All: Is it possible to replace the delegate with a function pointer that will use the cdecl calling convention? Thanks.
11
by: Florian A. | last post by:
Hi everyone! I'm trying to write a global hook in C# and C++/CLI. I'm almost done if there wasn't this little delegate problem. I get the function pointer to a delegate and pass it to my...
4
by: ^MisterJingo^ | last post by:
Hi all, I've been trying to get my head around delegates. The book i'm using had a single example, not much explaination, and didn't show how to set up a delegate and pass variables in and out...
5
by: Richard MSL | last post by:
I have an application in managed C++, and a method in C# that I call. But now I want to add the ability to tell the C# method a specific method in my C++ assembly to call back to. For example, to...
26
by: raylopez99 | last post by:
Here is a good example that shows generic delegate types. Read this through and you'll have an excellent understanding of how to use these types. You might say that the combination of the generic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.