Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Communications
Message
From
06/06/2003 23:34:19
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Communications
Miscellaneous
Thread ID:
00797561
Message ID:
00797561
Views:
47
I need use Windows API control the serial port,But I don,t know,What,s Wrong transmit data unsuccess.

This is my Code:

#DEFINE GENERIC_READ 0x80000000
#DEFINE GENERIC_WRITE 0x40000000
#DEFINE OPEN_EXISTING 3
#DEFINE FILE_FLAG_OVERLAPPED 0x40000000

DECLARE INTEGER CreateFile IN kernel32;
STRING lpFileName, INTEGER dwDesiredAccess, INTEGER dwShareMode,;
INTEGER lpSecurityAttributes, INTEGER dwCreationDisposition,;
INTEGER dwFlagsAndAttributes, INTEGER hTemplateFile

DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject

DECLARE INTEGER WriteFile IN kernel32 INTEGER hFile,;
STRING @ lpBuffer,INTEGER nBt2Write,INTEGER @ lpBtWritten,INTEGER lpOverlapped

DECLARE INTEGER ReadFile IN kernel32 INTEGER hFile,;
STRING @ lpBuffer,INTEGER nNumberOfBytesToRead,INTEGER @ lpNumberOfBytesRead, INTEGER lpOverlapped

ICDEV = CreateFile('COM1', GENERIC_READ+GENERIC_WRITE, 0,0,;
OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0)

outdata=chr(65)+chr(66)+chr(67)
indata=space(6)
LOCAL j,p
j=0

&&What,s wrong WriteFile unsuccess
a=WriteFile(ICDEV,@OUTDATA,3,@j,0)

b=ReadFile(ICDEV,@indata,3,@j,0)

= CloseHandle(ICDEV)
Next
Reply
Map
View

Click here to load this message in the networking platform