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. C#
  4. sending string data to parallel port?

sending string data to parallel port?

Scheduled Pinned Locked Moved C#
csharpquestion
3 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.
  • R Offline
    R Offline
    Rohit Dev
    wrote on last edited by
    #1

    hi everyone, is there any way through which i can send sring data to a parallel port using C#.net... thanks in advance...

    L 1 Reply Last reply
    0
    • R Rohit Dev

      hi everyone, is there any way through which i can send sring data to a parallel port using C#.net... thanks in advance...

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi yes there is. you can open the Parallel port open as a file and use FileStream to write on it. something like this: public class ParallelWriter { //Constants for dwFlagsAndAttributes: public const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000; //Constants for dwCreationDisposition: public const UInt32 OPEN_EXISTING = 3; //Constants for dwDesiredAccess: public const UInt32 GENERIC_READ = 0x80000000; public const UInt32 GENERIC_WRITE = 0x40000000; [DllImport("kernel32.dll", SetLastError=true)] private static extern IntPtr CreateFile(String lpFileName, UInt32 dwDesiredAccess, UInt32 dwShareMode, IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition, UInt32 dwFlagsAndAttributes, IntPtr hTemplateFile); private FileStream strm; public FileStream Stream { get { return strm; } } public ParallelWriter(string Port) { IntPtr Handle = CreateFile(Port,GENERIC_READ|GENERIC_WRITE,0,IntPtr.Zero,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,IntPtr.Zero); strm = new FileStream(Handle,FileAccess.ReadWrite,true,1,true); } } now just use the Stream to write your data to the Parallelport greets m@u

      R 1 Reply Last reply
      0
      • L Lost User

        Hi yes there is. you can open the Parallel port open as a file and use FileStream to write on it. something like this: public class ParallelWriter { //Constants for dwFlagsAndAttributes: public const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000; //Constants for dwCreationDisposition: public const UInt32 OPEN_EXISTING = 3; //Constants for dwDesiredAccess: public const UInt32 GENERIC_READ = 0x80000000; public const UInt32 GENERIC_WRITE = 0x40000000; [DllImport("kernel32.dll", SetLastError=true)] private static extern IntPtr CreateFile(String lpFileName, UInt32 dwDesiredAccess, UInt32 dwShareMode, IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition, UInt32 dwFlagsAndAttributes, IntPtr hTemplateFile); private FileStream strm; public FileStream Stream { get { return strm; } } public ParallelWriter(string Port) { IntPtr Handle = CreateFile(Port,GENERIC_READ|GENERIC_WRITE,0,IntPtr.Zero,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,IntPtr.Zero); strm = new FileStream(Handle,FileAccess.ReadWrite,true,1,true); } } now just use the Stream to write your data to the Parallelport greets m@u

        R Offline
        R Offline
        Rohit Dev
        wrote on last edited by
        #3

        hi, thanx for ur response.. After getting the strm how will i connect to parallel port to send this data... can u give me the code for the parallel port connection....

        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