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

calling unmanaged dll

hello,
im calling a function from an unmanaged dll which takes a ref to structure
as an argument.
one of the struct's fields is an address to a callback function/event(it
depends on you what to choose). It works asynchronously, modyfies given
structure and calls callback/event when finished.

How can i make it work in c#? can i use events?
Can i wait for the dll function to finish within c# method that called it?
Do i declare address to a function in structure as an IntPtr?

please help a newbie :)
Nov 15 '05 #1
2 1893
Have a look at delegates. Create a delegate like this

delegate void MyDelegate (int param);

use it in the declare like this

extern void MyDeclare(MyDelegate Address)

call it like this

MyDeclare(new MyDelegate(CallBackFunc))

void CallBackFunc(int someparam)
{
//callback will come here.
}

--
Michael Culley
"adrin" <ad***@adrin.adrin> wrote in message news:Xn*****************************@193.110.122.8 0...
hello,
im calling a function from an unmanaged dll which takes a ref to structure
as an argument.
one of the struct's fields is an address to a callback function/event(it
depends on you what to choose). It works asynchronously, modyfies given
structure and calls callback/event when finished.

How can i make it work in c#? can i use events?
Can i wait for the dll function to finish within c# method that called it?
Do i declare address to a function in structure as an IntPtr?

please help a newbie :)

Nov 15 '05 #2
Here you have a description of how to implement callback functionality for
P/Invoke with a sample:

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

You will just use other parameter types.

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply

"adrin" <ad***@adrin.adrin> wrote in message
news:Xn*****************************@193.110.122.8 0...
hello,
im calling a function from an unmanaged dll which takes a ref to structure
as an argument.
one of the struct's fields is an address to a callback function/event(it
depends on you what to choose). It works asynchronously, modyfies given
structure and calls callback/event when finished.

How can i make it work in c#? can i use events?
Can i wait for the dll function to finish within c# method that called it?
Do i declare address to a function in structure as an IntPtr?

please help a newbie :)


Nov 15 '05 #3

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

Similar topics

4
by: jarmopy | last post by:
Hi, I have made a service with C# and calling that service class from another C# program with remoting. (Referendes from the calling program) That service class is configured so that garpage...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
0
by: monika.saxena | last post by:
Hi all, In one of my projects which is a web based application in asp.net, a third party tool - "Frontline Solver DLL" (It is an unmanaged DLL and ..NET is calling it using the PInvoke) is used....
1
by: Leftie | last post by:
Folks, I'm trying to call an unmanaged function from VB.NET and keep getting "Object reference not set to an instance of an object" error. The code that i wrote can be found at:...
1
by: MC-Advantica | last post by:
Does anyone have a simple "Hello World" like application that demonstrates unmanaged C++ calling managed C++ developed in VS2005? I'm confused by many posts as they discuss managed extensions from...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
3
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.