03-07-2007, 19:41
|
|
|
|
חבר מתאריך: 04.08.02
הודעות: 4,468
|
|
במקרה שאתה עובד עם WinAPI אז:
קוד:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
HANDLE hCom;
TCHAR *pcCommPort = TEXT("COM1");
hCom = CreateFile( pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, // must be opened with exclusive-access
NULL, // default security attributes
OPEN_EXISTING, // must use OPEN_EXISTING
0, // not overlapped I/O
NULL // hTemplate must be NULL for comm devices
);
if (hCom == INVALID_HANDLE_VALUE)
{
// Handle the error.
printf ("CreateFile failed with error %d.\n", GetLastError());
return (1);
}
// code contineus here
return 0;
קריאה - עם ReadFile
כתיבה - WriteFile
_____________________________________
C pogrammers never die. They are just cast into void.
|