Is there any equivalent function in C# for the windows functions such as PurgeComm

  • Thread starter Thread starter Vidya Bhagwath
  • Start date Start date
V

Vidya Bhagwath

Hello Experts,
I am having C++ code. Now I am porting that C++ code to the Visual
C#.NET. In my C++ code I used the windows functions such as
"PurgeComm", "SetCommTimeouts"... etc. How can I port all these
functions to the Visual C#.NET? I am very much new to Visual C#.NET.
So I don't know much regarding the C#. Can anybody help me regarding
this?
Thanks in advance for any help.

Regards,
Vidya Bhagwath
 
You can still use API's in C#. You need to add the DllImport attribute.

Eg:
[DllImport("user32.dll",EntryPoint="GetSystemMetrics")]
public static extern int GetSystemMetrics(int abc);

[DllImport("user32.dll",EntryPoint="GetWindowDC")]
public static extern IntPtr GetWindowDC(Int32 ptr);

Gabriel Lozano-Morán
 
Gabriel Lozano-Morán said:
You can still use API's in C#. You need to add the DllImport attribute.

Eg:
[DllImport("user32.dll",EntryPoint="GetSystemMetrics")]
public static extern int GetSystemMetrics(int abc);

[DllImport("user32.dll",EntryPoint="GetWindowDC")]
public static extern IntPtr GetWindowDC(Int32 ptr);

Gabriel Lozano-Morán

Vidya Bhagwath said:
Hello Experts,
I am having C++ code. Now I am porting that C++ code to the Visual
C#.NET. In my C++ code I used the windows functions such as
"PurgeComm", "SetCommTimeouts"... etc. How can I port all these
functions to the Visual C#.NET? I am very much new to Visual C#.NET.
So I don't know much regarding the C#. Can anybody help me regarding
this?
Thanks in advance for any help.

Regards,
Vidya Bhagwath

O.K. Thanks Gabriel Lozano-Morán. I will try this. Hope this will be usefull to me.

Regards,
Vidya Bhagwath
 
Back
Top