473,804 Members | 3,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4800
apm,

You can only do this in .NET 2.0. You can apply the
UnmanagedFuncti onPointer 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.co m

"apm" <Co*********@Ad sorptionProcess Modeling.com> wrote in message
news:wCgUe.3641 $nq.3584@lakere ad05...
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.c om> wrote in
message news:eN******** ******@TK2MSFTN GP14.phx.gbl...
apm,

You can only do this in .NET 2.0. You can apply the
UnmanagedFuncti onPointer 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.co m

"apm" <Co*********@Ad sorptionProcess Modeling.com> wrote in message
news:wCgUe.3641 $nq.3584@lakere ad05...
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*********@Ad sorptionProcess Modeling.com> wrote in message
news:u7kUe.3653 $nq.1829@lakere ad05...

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

You can only do this in .NET 2.0. You can apply the
UnmanagedFuncti onPointer 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.co m

"apm" <Co*********@Ad sorptionProcess Modeling.com> wrote in message
news:wCgUe.3641 $nq.3584@lakere ad05...
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******** ******@TK2MSFTN GP14.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*********@Ad sorptionProcess Modeling.com> wrote in message
news:u7kUe.3653 $nq.1829@lakere ad05...

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

You can only do this in .NET 2.0. You can apply the
UnmanagedFuncti onPointer 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.co m

"apm" <Co*********@Ad sorptionProcess Modeling.com> wrote in message
news:wCgUe.3641 $nq.3584@lakere ad05...
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
2968
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 p3); The parameters here can be read either in the forward order from p1 till p3 or reverse order from p3 till p1. Can anyone explain what is the advantage/disadvantage of either of
11
2341
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 correct, and if so, does anyone have an example ? Thanks !!
3
25290
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 user control to invoke a method in the parent form. This code doesn't seem to work for me, I've tried it a number of times with very simple test cases (A user control with a single button and a parent form with a single text box) and it always...
1
2844
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 pass to it delegate to managed object method. I know how to do it from C# - DllImport etc. I suspect I can declare "stub" method using those attributes, so it will actually reference "C" method, and call this stub, letting marshaler to do the...
3
228
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
9084
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 hook.dll. The delegate gets called for a few seconds but then the delegate seems to be relocated on the CLR heap. If tried using a GCHandle but as far as I can tell this only prevents the garbage collector from collecting my delegate and doesn't stop...
4
2022
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 of the functions it refers to. So I've been playing around and came up with he following code. I know it doesn't do much, but I just wanted to fit together delegates and parameter passing: //////////////// Code start
5
1681
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 have the C++ call a sort routine in C#, and send it a compare method, which the C## would call back to. I know that within C# pointing to methods is done with delegates, but is it possible between C++ and C#? Is there an example of this somewhere...
26
3632
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 delegate type expression in just the right place and a well-named method means we can almost read the code out loud and understand it without even thinking. Note that since 'boxing' and 'unboxing' is involved (I think), you don't get what you...
0
9704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7608
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.