General information
Category:
Windows API functions
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only