H
Hadi
Can C# uses a native non-COM dll? I tried to add reference to an non-COM dll
and I can't.
thanks,
Hadi
and I can't.
thanks,
Hadi
Ramiro Calderón said:Hi Hadi,
When using native dlls, you don't need to reference the dll file
explicitly. All you have to do is use .NET's PInvoke services:
Here's an example:
using System.Runtime.InteropServices;
class PlatformInvokeTest
{
[DllImport("user32.dll")]
/* You have to write the dll method's signature in c# as 'extern'*/
public static extern int MessageBoxA(
int h, string m, string c, int type);
public static int Main()
{
return MessageBoxA(0, "Hello World!", "My Message Box", 0);
}
}
If you want further informationm there's a few examples in MSDN
HTH,
Ramiro
Can C# uses a native non-COM dll? I tried to add reference to an non-COM dll
and I can't.
thanks,
Hadi
Where should I put my dll to invoke? If I
just say DllImport("dll.dll") how would c# know where the location of my
dll?
Hadi said:What if my dll is not Windows dll? Where should I put my dll to invoke? If I
just say DllImport("dll.dll") how would c# know where the location of my
dll?
thanks
non-COMRamiro Calderón said:Hi Hadi,
When using native dlls, you don't need to reference the dll file
explicitly. All you have to do is use .NET's PInvoke services:
Here's an example:
using System.Runtime.InteropServices;
class PlatformInvokeTest
{
[DllImport("user32.dll")]
/* You have to write the dll method's signature in c# as 'extern'*/
public static extern int MessageBoxA(
int h, string m, string c, int type);
public static int Main()
{
return MessageBoxA(0, "Hello World!", "My Message Box", 0);
}
}
If you want further informationm there's a few examples in MSDN
HTH,
Ramiro
Can C# uses a native non-COM dll? I tried to add reference to an