Share Pastebin
Guest
Public paste!

QueryDosDevice enumerator

By: a guest | Mar 20th, 2010 | Syntax: C | Size: 0.85 KB | Hits: 298 | Expires: Never
Copy text to clipboard
  1. #include <stdio.h>
  2. #include <windows.h>
  3.  
  4. void main()
  5. {
  6.   char szDosDevs[32768];
  7.   char szSymbol[8192];
  8.   char *pszDos;
  9.   char *pszSymbol;
  10.  
  11.   // get all dos device names separated by 0's
  12.   //
  13.   QueryDosDevice(NULL, szDosDevs, 32768);
  14.   pszDos = szDosDevs;
  15.  
  16.   // loop through the set of dos names
  17.   //
  18.   while (*pszDos)
  19.     {
  20.     printf("%-15s", pszDos); // write the dos name
  21.  
  22.     // get the translation of the dos name to the
  23.     // NT device name(s).
  24.     //
  25.     QueryDosDevice(pszDos, szSymbol, 8192);
  26.     pszSymbol = szSymbol;
  27.  
  28.     // print each of the names on a separate line
  29.     // names are separated in the szSymbol buffer
  30.     // by '0's
  31.     //
  32.     while (*pszSymbol)
  33.       {
  34.       printf("\t%s\n", pszSymbol);
  35.       pszSymbol += strlen(pszSymbol) + 1;
  36.       break;
  37.       }
  38.  
  39.     pszDos += strlen(pszDos) + 1;
  40.     }
  41.   return;
  42. }