CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2002
    Location
    Newton, NJ
    Posts
    7

    Win32 access to parallel port

    Any sample code available for Win32 application to directly access parallel port? Need to use parallel port outputs as discrete lines, not strobe data. Thanks.

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    The file input and output (I/O) functions ('CreateFile()', 'CloseHandle()', 'ReadFile()', 'ReadFileEx()', 'WriteFile()' and 'WriteFileEx()') provide the basic interface for opening and closing a communications resource handle and for performing read and write operations. Depending of what you are trying to do take also a look at the following functions...
    Code:
    // Parallel Device Callback Routines
    
    USHORT *DetermineIeeeModes(IN PDEVICE_EXTENSION Extension)
    
    NTSTATUS *IeeeFwdToRevMode(IN PDEVICE_EXTENSION Extension)
    
    NTSTATUS *IeeeRevToFwdMode(IN PDEVICE_EXTENSION Extension)
    
    NTSTATUS *NegotiateIeeeMode(IN PDEVICE_EXTENSION Extension,
                                IN USHORT ModeMaskFwd,
                                IN USHORT ModeMaskRev,
                                IN PARALLEL_SAFETY ModeSafety,
                                IN BOOLEAN IsForward)
    
    NTSTATUS *ParallelRead(IN PDEVICE_EXTENSION Extension,
                           IN PVOID Buffer,
                           IN ULONG NumBytesToRead,
                           OUT PULONG NumBytesRead,
                           IN UCHAR Channel)
    
    NTSTATUS *ParallelWrite(IN PDEVICE_EXTENSION Extension,
                            OUT PVOID Buffer,
                            IN ULONG NumBytesToWrite,
                            OUT PULONG NumBytesWritten,
                            IN UCHAR Channel)
    
    NTSTATUS *TerminateIeeeMode(IN PDEVICE_EXTENSION Extension)
    
    
    // Parallel Port Callback Routines
    
    NTSTATUS *ClearChipMode(IN PDEVICE_EXTENSION Extension, IN UCHAR ChipMode)
    
    NTSTATUS *DeselectDevice(IN PVOID Context, IN PVOID DeselectCommand)
    
    VOID *FreePort(IN PVOID Context)
    
    VOID *FreePortFromInterruptLevel(IN PVOID Context)
    
    ULONG *QueryNumWaiters(IN PVOID Extension)
    
    BOOLEAN *TryAllocatePort(IN PVOID Context)
    
    BOOLEAN *TryAllocatePortAtInterruptLevel(IN PVOID Context)
    
    NTSTATUS *TrySelectDevice(IN PVOID Context, IN PVOID TrySelectCommand)
    
    NTSTATUS *TrySetChipMode(IN PDEVICE_EXTENSION Extension, IN UCHAR ChipMode)
    All functions are coming from the Windows DDK (Driver Development Kit). For further information look within the MSDN (http:// msdn.microsoft.com)...

  3. #3
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    I have a few links around the bottom of my Device Information page. You say "Win32 application" but the solution might depend somewhat on the version of Windows. However you can look at those other sites for answers to that also.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured