如何使用c ++获取system32目录的完整路径? [英] How to get the full path to system32 directory with c++?

查看:65
本文介绍了如何使用c ++获取system32目录的完整路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然大多数时候是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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆