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

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
 
G

Gabriel Lozano-Morán

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
 
V

Vidya Bhagwath

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top