473,407 Members | 2,315 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,407 software developers and data experts.

Interop problem (.NET 2.0)

Hello,

I need to load in my C# .nET 2.0 application an dll (not COM)written in
Delphi. The dll has a function which returns a pointer to an IModule
interface defined in that dll.
How do I declare my delegate and call the unmanaged function?

I did something like that;

//here unsure if this should be the signature ??

internal delegate MyDelg (out IntPtr IModule);

IntPtr hModule = LoadLibrary("mydll.dll");
//if the handle is valid try to call members
if (hModule != IntPtr.Zero)
{
//get the function pointer
IntPtr fptr = GetProcAddres(hModule, "GetInterface");
if (fptr != IntPtr.Zero)
{
MyDelg mgi = Marshal.GetDelegateForFunctionPointer(fptr,
typeof(MyDelg));

//here unsure ??
IntPtr ptrModuleInterface;
mgi(out ptrModuleInterface);
}
FreeLibrary(hModule);

Please help me to figure out the proper way to invoke that unmanged
function.

Thank you
Ad*@yahoo.com

*** Sent via Developersdex http://www.developersdex.com ***
Mar 14 '06 #1
1 1460
And what is this IModule pointer pointing to? You can't call Interfaces, you
can only call functions.

Willy.
"Ada Byron" <ga***********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
| Hello,
|
| I need to load in my C# .nET 2.0 application an dll (not COM)written in
| Delphi. The dll has a function which returns a pointer to an IModule
| interface defined in that dll.
| How do I declare my delegate and call the unmanaged function?
|
| I did something like that;
|
| //here unsure if this should be the signature ??
|
| internal delegate MyDelg (out IntPtr IModule);
|
| IntPtr hModule = LoadLibrary("mydll.dll");
| //if the handle is valid try to call members
| if (hModule != IntPtr.Zero)
| {
| //get the function pointer
| IntPtr fptr = GetProcAddres(hModule, "GetInterface");
| if (fptr != IntPtr.Zero)
| {
| MyDelg mgi = Marshal.GetDelegateForFunctionPointer(fptr,
| typeof(MyDelg));
|
| //here unsure ??
| IntPtr ptrModuleInterface;
| mgi(out ptrModuleInterface);
| }
| FreeLibrary(hModule);
|
| Please help me to figure out the proper way to invoke that unmanged
| function.
|
| Thank you
|
|
| Ad*@yahoo.com
|
| *** Sent via Developersdex http://www.developersdex.com ***
Mar 15 '06 #2

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

Similar topics

0
by: keefah | last post by:
Hi, I'm writing a C# web app that uses Outlook to send email. I use a reference to the Microsoft Outlook 11.0 Object Library, but it's giving me problems. I tracked down some stuff on the Net...
0
by: lacour | last post by:
I can't seem to figure out the difference between adding a COM dll reference in VS2003 and by using TLBIMP. I have a COM dll that references another COM dll, and I want the syntax of my...
8
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be...
0
by: keefah | last post by:
Hi, I'm writing a C# web app that uses Outlook to send email. I use a reference to the Microsoft Outlook 11.0 Object Library, but it's giving me problems. I tracked down some stuff on the Net...
2
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a...
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
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
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
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,...
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.