Getting the Windows Drivers Directory
Is there an official / proper method of getting Windows’ drivers directory or do you just concatenate "\\Drive开发者_StackOverflow中文版rs"
to GetSystemDirectory()
?
To be clear, I mean the Drivers
directory that is in the system directory (eg System32
). Yes, drivers can technically be anywhere, but is there an official way (eg a function) to get this specific directory?
There is no special folder for drivers. The special folders are CSLIDs (see http://msdn.microsoft.com/en-us/library/bb762494(VS.85).aspx.
If it was a special folder then you could use the SHGetSpecialFolderPath (see http://msdn.microsoft.com/en-us/library/bb762204(VS.85).aspx)
It's hard-coded into the kernel, although drivers don't have to be loaded from there. Here's some bits taken from various parts of the I/O subsystem, which loads drivers:
#define SYSTEM32_DRIVERS_DIR (L"\\System32\\drivers\\")
...
pathLength = sizeof(L"\\SystemRoot\\System32\\Drivers\\") - sizeof(UNICODE_NULL);
path = L"\\SystemRoot\\System32\\Drivers\\";
...
精彩评论