You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1006 B
47 lines
1006 B
|
|
#include "windows.h"
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
#define BIGREAD 256000
|
|
unsigned char readbuff[BIGREAD];
|
|
|
|
void main(int argc,char *argv[]) {
|
|
|
|
HANDLE hFile;
|
|
char *MyPort = "COM1";
|
|
|
|
if (argc > 1) {
|
|
|
|
MyPort = argv[1];
|
|
|
|
}
|
|
|
|
printf("Getting file type of %s\n",MyPort);
|
|
|
|
if ((hFile = CreateFile(
|
|
MyPort,
|
|
GENERIC_READ,
|
|
0,
|
|
NULL,
|
|
CREATE_ALWAYS,
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
NULL
|
|
)) != ((HANDLE)-1)) {
|
|
|
|
printf("We successfully opened the %s port.\n",MyPort);
|
|
|
|
printf("The file type is: 0x%x\n",GetFileType(hFile));
|
|
|
|
CloseHandle(hFile);
|
|
|
|
} else {
|
|
|
|
DWORD LastError;
|
|
LastError = GetLastError();
|
|
printf("Couldn't open the %s device.\n",MyPort);
|
|
printf("Status of failed open is: %x\n",LastError);
|
|
|
|
}
|
|
|
|
}
|