473,789 Members | 2,957 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C library wrapper

Hey,

I'm currently writing a C# wrapper for a library that was originally written
in C.
The wrapper is basiclly working, but I'm having trouble writing a wrapper
for this kind of code segment:

typedef int (*callback_func tion)(char *string);
__declspec(dlli mport) BOOL DLL(some_functi on)(callback_fu nction
some_ther_funct ion);

I was thinking about using delegations in order to wrap this up (will this
even work?), but I'm not sure thats the right way to do this.

Any suggestions on how to do this?

Thanks,
Yaniv Oliver
Nov 16 '05 #1
1 1829
Check out this article:

http://msdn.microsoft.com/library/de...backSample.asp

Regards,
Joakim

Yaniv Oliver wrote:
Hey,

I'm currently writing a C# wrapper for a library that was originally written
in C.
The wrapper is basiclly working, but I'm having trouble writing a wrapper
for this kind of code segment:

typedef int (*callback_func tion)(char *string);
__declspec(dlli mport) BOOL DLL(some_functi on)(callback_fu nction
some_ther_funct ion);

I was thinking about using delegations in order to wrap this up (will this
even work?), but I'm not sure thats the right way to do this.

Any suggestions on how to do this?

Thanks,
Yaniv Oliver

Nov 16 '05 #2

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

Similar topics

1
2289
by: Mark McEahern | last post by:
I just wrote a very simple wrapper for the PayFlow Pro SDK (see below). A friend of mine did this before, but I didn't have access to his source, so I took it as a learning opportunity for me to write a C wrapper. I did a little searching to see whether anyone had done anything like this for Python. I didn't find anything. I did find that PHP comes with an extension for PayFlow Pro that you can compile into the language:
0
2483
by: Claire | last post by:
Hi Ive been using Mattias Sjögren's example at http://www.msjogren.net/dotnet/eng/samples/dotnet_dynpinvoke.asp to load an unmanaged 3rd party dll dynamically when my object is created. Calling the "CreateDllAssembly" function below does this. When my wrapper is disposed of, I want the dll to be unloaded from memory. See the "dispose" function below. All seems to work ok on the first instance of my wrapper class. (I only
1
1717
by: Steve Terepin | last post by:
I've found some rather worrying articles (Mixed Mode Library Assembly bug, Richard Grimes, Windows Developer Network Sept 2003 ; and Knowledge Base Article 814472 ) that point out the need to use the /noentry switch and an explicit initialisation procedure, to be able to safely use Managed C++ assemblies that call down into standard C library functions. Could someone confirm that I've understood this properly ? I'm writing some Managed...
1
7162
by: Adam Clauss | last post by:
I have an unmanaged C++ library that I need to use through C#. I created a Managed C++ class library and through it wrote a wrapper class to call what I need. However, one of the methods (an Initialize function in the unmanaged library) crashes everytime I call it. Initialize calls another function 'GetInstance' (a static member function of a class) which looks something like: CLibConfig& CLibConfig::GetInstance()
5
2164
by: Octal | last post by:
How does the lambda library actually works. How does it know how to evaluate _1, how does it recognize _1 as a placeholder, how does it then calculate _1+_2, or _1+2 etc. The source files seem a bit complicated so any explanation would be appreciated. Thanks
1
2368
by: dfj225 | last post by:
While my question doesn't pertain specifically to python programming, it is a result of developing a python module, so I'm hoping someone here might have experience with this issue. So, first a little background to how the system works right now. I am developing a module for Python. The original code is written in C++ and I am creating a wrapper using Boost.Python. The C++ code for the module makes calls into a library that in turn...
3
2959
by: jonlynch71 | last post by:
Hi, I have a statically-linked C library (.lib) that I need to be able to access from C#. I understand that the best way to do this is to code a C++ managed wrapper. How do I create this wrapper? One of the functions in this library is as follows: int *func2 (int *ary, int n, char *str)
2
5719
by: Serman D. | last post by:
Hi all, I'm trying to complete the samples from the excellent 2003 developerWorks article "Bringing the Power of Regular Expression Matching to SQL" by Knut Stolze: http://tinyurl.com/3bhrnn I've managed to compile and link the C code from "Listing 5", the regexpSimple() wrapper (see link). The build options are pretty much
1
1672
by: Łukasz Z±bik | last post by:
I have project that uses managed c++ where I use c - library, this library contains some variables named generic, during compilation I get error: Error 1 error C2146: syntax error : missing ';' before identifier 'generic', Problem is that in dotNet generic is a keyword, and I cannot change this name becouse I have only lib file and includes. How to solve this problem? -- pozdrawiam Łukasz
0
9666
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
9511
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
10410
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
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
9984
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...
0
6769
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
5418
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2909
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.