Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Communications
Message
De
07/06/2003 14:51:38
 
 
À
06/06/2003 23:34:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Divers
Thread ID:
00797561
Message ID:
00797668
Vues:
12
>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)

Liu,

Don't use FILE_FLAG_OVERLAPPED in CreateFile. If this flag is used then the last parameter in WriteFile must be a valid OVERLAPPED structure (cannot be NULL)

HTH
Herman
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform