473,396 Members | 1,892 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,396 software developers and data experts.

Calling C# Callbacks from C++ dll?

84
Hi Guys,
I have a C++ third party dll which does some algorithms for us and seldomly passes data back. Now we were wanting to use DLLIMPORT from c# to utilize these functions from C++ but are having some issues.

Here are the function declaration in C++.

Expand|Select|Wrap|Line Numbers
  1.  
  2. int DoWSUpdate(LPSTR lpName,LPSTR lpPath,LPSTR lpBinPath,MyCallBack pMyCallBack) 
  3.  
  4. void (CALLBACK *MyCallBack)(DWORD dStatus,LPSTR Cur,long Complete,long AllComplete,LPSTR szDescript)
  5.  
To utilize the above i have written the following c# code.

Expand|Select|Wrap|Line Numbers
  1.  
  2. public delegate void MyCallBack(int dStatus,  string Cur, long Complete, long AllComplete, string szDescript);
  3.  
  4. [DllImport("CPLUS.dll", SetLastError = true, EntryPoint = "DoWSUpdate")]
  5. public static extern int DoWSUpdate([MarshalAs(UnmanagedType.LPStr)] string lpName, [MarshalAs(UnmanagedType.LPStr)] string lpPath, [MarshalAs(UnmanagedType.LPStr)] string lpBinPath, [MarshalAs(UnmanagedType.FunctionPtr)] MyCallBack pMyCallBack);
  6.  
  7.  
Please advise what am i doing wrong here as each time i try to invoke DoWSUpdate i get

Unable to find an entry point named 'DoWSUpdate' in DLL 'CPLUS.dll'.

Please help guys.......
Oct 19 '09 #1
0 1307

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Melissa Wallis | last post by:
I have a class with 5 callbacks. Two of the callbacks work fine but the others don't. The main difference is that the callbacks that don't work are composed of a sequence of structs. I noticed a...
9
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so...
5
by: Praveen Srinivasan | last post by:
Hi all, Are there any important issues that one should be aware of when calling C++ functions from C? In particular, I'm passing a function pointer to a C routine in a library, and in that...
0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
5
by: Christopher Jastram | last post by:
I'm a self-taught programmer, so this might be a pretty dumb question. If it is, please point me in the right direction and I shall apologize profusely. I have a question regarding C++ and...
4
by: apm | last post by:
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.
12
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
9
by: zholthran | last post by:
Hi folks, after reading several threads on this issue (-> subject) I fear that I got a problem that cannot easily be solved by the offered workarounds in an acceptable way, at least not with my...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
6
by: Ole Nielsby | last post by:
VC has a __cdecl specifier which allows functions and methods to be called with varying parameter count. (I understand this is the default for functions in general but in VC, instances use...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.