3

From the microsoft-doku:

The "\\.\" prefix will access the Win32 device namespace instead of the Win32 file namespace. This is how access to physical disks and volumes is accomplished directly, without going through the file system, if the API supports this type of access. You can access many devices other than disks this way (using the CreateFile and DefineDosDevice functions, for example).

For example, if you want to open the system's serial communications port 1, you can use "COM1" in the call to the CreateFile function. This works because COM1–COM9 are part of the reserved names in the NT namespace, although using the "\\.\" prefix will also work with these device names.

My Question is, what is available in this namespace. Is there a list of devices and where can I get it ? (I think I did not understand this topic. When I hear device I think of some sort of file in a directory.)

EDIT:

Ok, I will answer my own question. There is a software called WinObj , with which one can see the information .

1
  • You can post that as an answer. Mar 24, 2016 at 21:05

2 Answers 2

2

Ok, I will answer my own question. There is a software called WinObj , with which one can see the information .

1

You can use the QueryDosDevice Win32 API call to get all Win32 device names.

#include <windows.h>
#include <stdio.h>

#define DEVBUFSIZ (128 * 1024)      /* No recommended value - ~14K for me */
int main(int argc, char** argv)
{
    wchar_t devicenames[DEVBUFSIZ]  = L"";
    int     error                   = 0;
    int     wchar_count             = 0;

    wchar_count = QueryDosDeviceW(
            NULL,       /* lpDeviceName - NULL gives all */
            devicenames,
            DEVBUFSIZ);
    if (wchar_count == 0) {
        fprintf(stderr, "QueryDosDeviceW failed with error code %d\n", error);
        return 1;
    }
    for (int i = 0; i < wchar_count; i++) {
        if (devicenames[i] == '\0')
            devicenames[i] = '\n';
    }
    wprintf(L"%s", devicenames);
    return 0;
}

As an aside, WinObj does not primarily list Win32 device names, it lists Windows NT object names. Though the Win32 device names can be found under the GLOBAL?? node in WinObj.

See "More Information" in https://support.microsoft.com/en-us/kb/100027

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.