How to create new object in C# for reading COM port.
-
How to create new object in C# for reading COM port. I am having 'Comet.xyz' object. this object comes from COM port. please tell me how can i convert following code into c#. /////////code in delphi Coment := CreateOleObject('Comet.xyz'); Coment.COmPort="COM1"; please convert it into C#
-
How to create new object in C# for reading COM port. I am having 'Comet.xyz' object. this object comes from COM port. please tell me how can i convert following code into c#. /////////code in delphi Coment := CreateOleObject('Comet.xyz'); Coment.COmPort="COM1"; please convert it into C#
You can make a reference to the object... If not then you can use "Late Binding",...
Type type = Type.GetTypeFromProgID("WScript.Shell");
Object oShell = Activator.CreateInstance(type);
Object[] oArgs = {"notepad.exe"};
type.InvokeMember("Run", System.Reflection.BindingFlags.InvokeMethod, Type.DefaultBinder, oShell, oArgs);I'm not home in C#, but in VB.Net with "Option Strict Off" you can also just write
Dim type As Type = Type.GetTypeFromProgID("WScript.Shell")
Dim oShell As Object = Activator.CreateInstance(type)
oShell.Run "notepad.exe"GTH
It feels good to learn and achieve
modified on Thursday, April 9, 2009 5:58 PM