473,395 Members | 1,440 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.

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 1458
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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...
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...

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.