Tips for using Win32 Device Namespaces in APIs
Win32 Device Namespaces
Device Access: \\.\
Device Access: \\.\
Similar to working with the files in /dev on a *nix system, use the “\\.\” prefix to access Win32 device namespaces instead of the standard Win32 file namespace that you get using single backslashes. Remember that you’re just specifying a handle, or an index to something in the kernel. A device could be specified for lpFileName to access a physical disk, for instance.
|
1 2 3 4 5 6 7 8 9 |
HANDLE WINAPI CreateFile( __in LPCTSTR lpFileName, __in DWORD dwDesiredAccess, __in DWORD dwShareMode, __in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes, __in DWORD dwCreationDisposition, __in DWORD dwFlagsAndAttributes, __in_opt HANDLE hTemplateFile ); |
However, this is definitely implementation specific. You know the drill — be prepared for microsoft to pull the rug out from under your feet by changing the implementation in any service pack or update.
Escape Parsing: \\?\
For file I/O, the “\\?\” prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. The \\?\ can be a tricky one to work it as some APIs may not support it.
