如何使用c ++获取system32目录的完整路径? [英] How to get the full path to system32 directory with c++?
问题描述
虽然大多数时候是C:\WINDOWS\system32
,但有时也可以在D
分区或类似的,如何以编程方式获取?
可以调用 Windows API 函数 SHGetFolderPath
并请求 CSIDL_SYSTEM
.
在 Windows Vista 及更高版本中,您可以调用 SHGetKnownFolderPath
并询问 FOLDERID_System
.SHGetFolderPath
只是在更高版本的 Windows 中封装此函数,但如果您希望您的软件在 Windows XP 上运行,则需要使用 SHGetFolderPath
.>
Although most of the time it's C:\WINDOWS\system32
, but sometimes it can be in D
partition or alike, how to get it programatically?
You can call the Windows API function SHGetFolderPath
and ask for CSIDL_SYSTEM
.
In Windows Vista and later, you can call SHGetKnownFolderPath
and ask for FOLDERID_System
. SHGetFolderPath
is just a wrapper around this function in later versions of Windows, but if you want your software to run on Windows XP, you'll need to use SHGetFolderPath
.
这篇关于如何使用c ++获取system32目录的完整路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!