Leaked source code of windows server 2003
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

  1. #include "windows.h"
  2. #include <string.h>
  3. #include <stdio.h>
  4. #define BIGREAD 256000
  5. unsigned char readbuff[BIGREAD];
  6. void main(int argc,char *argv[]) {
  7. HANDLE hFile;
  8. char *MyPort = "COM1";
  9. if (argc > 1) {
  10. MyPort = argv[1];
  11. }
  12. printf("Getting file type of %s\n",MyPort);
  13. if ((hFile = CreateFile(
  14. MyPort,
  15. GENERIC_READ,
  16. 0,
  17. NULL,
  18. CREATE_ALWAYS,
  19. FILE_ATTRIBUTE_NORMAL,
  20. NULL
  21. )) != ((HANDLE)-1)) {
  22. printf("We successfully opened the %s port.\n",MyPort);
  23. printf("The file type is: 0x%x\n",GetFileType(hFile));
  24. CloseHandle(hFile);
  25. } else {
  26. DWORD LastError;
  27. LastError = GetLastError();
  28. printf("Couldn't open the %s device.\n",MyPort);
  29. printf("Status of failed open is: %x\n",LastError);
  30. }
  31. }