T
Thomas Johansen
Hi
I have an GetObject() function in my "old" unmangaed C++ compiled DLL. I
need to call some function in this dll, so I use DllImport in my C#
application.
This is how I do it: (This code works)
[DllImport("ITSIOU.dll", EntryPoint="?GetObjectW@CIODriver@@SAPAV1@XZ",
CallingConvention=CallingConvention.Cdecl)]
static extern int GetObject();
public ITSIOServiceInterface()
{
// Call GetObject to initialize ITSIOu.DLL.
CIODriver = new IntPtr(GetObject());
// Check for success
if( CIODriver.ToInt32() == 0)
{
// Error. No IO subsystem ready
return;
}
}
The CallingConvention isn't nesecary in my case (the dll is compiled with
Cdecl). I thought default was StdCall, so why does it work without it ?
If I use EntryPoint="GetObjectW" or EntryPoint="GetObject" I get an
EntryPointNotFoundException.
So my question is:
1: Why can't I use a more friendly name like "GetObject" instead of
?GetObjectW@CIODriver@@SAPAV1@XZ. ? Any way of doing this ?
(Tried with "[DllImport("ITSIOU.dll", EntryPoint="GetObject",
CallingConvention=CallingConvention.Cdecl)]". No luck)
2: When using DllImport on other function, ex. CreateFile from kernel32.dll,
I can use "CreateFile" without using an "unfriendly" name as entry point.
Why is there no problem on other DLL's ? (And others I have tried ?)
Thomass
I have an GetObject() function in my "old" unmangaed C++ compiled DLL. I
need to call some function in this dll, so I use DllImport in my C#
application.
This is how I do it: (This code works)
[DllImport("ITSIOU.dll", EntryPoint="?GetObjectW@CIODriver@@SAPAV1@XZ",
CallingConvention=CallingConvention.Cdecl)]
static extern int GetObject();
public ITSIOServiceInterface()
{
// Call GetObject to initialize ITSIOu.DLL.
CIODriver = new IntPtr(GetObject());
// Check for success
if( CIODriver.ToInt32() == 0)
{
// Error. No IO subsystem ready
return;
}
}
The CallingConvention isn't nesecary in my case (the dll is compiled with
Cdecl). I thought default was StdCall, so why does it work without it ?
If I use EntryPoint="GetObjectW" or EntryPoint="GetObject" I get an
EntryPointNotFoundException.
So my question is:
1: Why can't I use a more friendly name like "GetObject" instead of
?GetObjectW@CIODriver@@SAPAV1@XZ. ? Any way of doing this ?
(Tried with "[DllImport("ITSIOU.dll", EntryPoint="GetObject",
CallingConvention=CallingConvention.Cdecl)]". No luck)
2: When using DllImport on other function, ex. CreateFile from kernel32.dll,
I can use "CreateFile" without using an "unfriendly" name as entry point.
Why is there no problem on other DLL's ? (And others I have tried ?)
Thomass