Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. How to create new object in C# for reading COM port.

How to create new object in C# for reading COM port.

Scheduled Pinned Locked Moved COM
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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#

    V 1 Reply Last reply
    0
    • L Lost User

      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#

      V Offline
      V Offline
      Vozzie2
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups