Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Writing data to lpt port using CreateFile(), is it possible
Message
From
15/04/1998 15:56:07
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Writing data to lpt port using CreateFile(), is it possible
Miscellaneous
Thread ID:
00092263
Message ID:
00092263
Views:
125
I want to write data to lpt1 port to control PCU customer display.
The only way to do using vfp native commands is "run copy fn lpt1"
but this is too low for disply control.

So the only possibility is to use API.

I tried the following command:

declare short CreateFile in win32api ;
string @lpFileName, ; && address of name of the file
integer dwDesiredAccess, ; && access (read-write) mode
integer dwShareMode, ; && share mode peab 0
string @lpSecurityAttributes,; && address of security descriptor
integer dwCreationDistribution, ; && how to create OPEN_EXISTING
integer dwFlagsAndAttributes, ; && file attributes
short htemplfile && handle of file with attributes to copy

declare integer GetLastError in win32api

*typedef struct _SECURITY_ATTRIBUTES {
* DWORD nLength
* LPVOID lpSecurityDescriptor
* BOOL bInheritHandle
*} SECURITY_ATTRIBUTES

secattr = chr(12) + repl( chr(0), 11 )
lcPORT = 'COM1'+chr(0)

I= createfile( @lcport, 0 , 0, @secattr, 3,0, 0 )
J=GETLASTERRor()
? i,j

But createfile return -1 and getlasterror() returns
87 ERROR_INVALID_PARAMETER!

How to write data to lpt1 port?

* Win32 api help says:
*Under Win32, CreateFile() is used to create a handle to a communications
* resource (for example, COM1). The fdwShareMode parameter must be 0
*(exclusive access), the fdwCreate parameter must be OPEN_EXISTING, and the
*hTemplate parameter must be NULL. Read, write, or read/write access can be
*specified and the handle can be opened for overlapped I/O.
*ReadFile() and WriteFile() are used for communciations I/O.
Andrus
Next
Reply
Map
View

Click here to load this message in the networking platform