Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Communications
Message
From
07/06/2003 11:38:59
 
 
To
07/06/2003 02:45:21
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00797561
Message ID:
00797633
Views:
13
Hi Craig
I have used MSCOMM ActiveX control ,but have so much difficult.so I need use Windows API control the serial port


>Is there a reason you can't use the MSCOMM ActiveX control?


>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)
Previous
Reply
Map
View

Click here to load this message in the networking platform