Native DLL from machine manufacturer to use on C# program

  • Thread starter Thread starter JinronCsharp
  • Start date Start date
J

JinronCsharp

Guest
Hi Everyone,

I have DLL that i need to use in my C# application. The first thing i need to do is to establish a COM PORT connection.
According to the manufacturer's DLL description, the parameters for OpenComport function are as follows:

HWND hwnd(IN) //Window Handle to receive message and
uint PortNum(IN) //Serial Port Number (Ex.) COM1 -> 1, COM2 -> 2.
return value: BOOL //Success to open Port : “TRUE”, Fail to open Port : “FALSE"

My problem is i cannot add the provided DLL as reference on my c# project.
I searched for the errors that I'm getting and found out that what I'm dealing with is a Native type DLL.

now i tried what everyone suggested using P/invoke but I'm still stuck on making a working OpenComPort Function.

using System.Runtime.InteropServices;

[DllImport("MyDLL.dll")]


Any help would be appreciated.

Thanks

Continue reading...
 
Back
Top