Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Writing data to lpt port using CreateFile(), is it possible
Message
De
15/04/1998 15:56:07
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Writing data to lpt port using CreateFile(), is it possible
Divers
Thread ID:
00092263
Message ID:
00092263
Vues:
126
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform