windows 环境变量 %SystemDrive% 和 %SystemRoot%
Windows 环境变量
2023-09-27 14:24:05 时间
%SYSTEMROOT% == c:\windows (or the root windows directory)
%SYSTEMDRIVE% == the drive windows is installed to (eg, C:\)
How can I get the system drive letter?
There's an environment variable called SystemDrive
which is set to the system drive (surprisingly enough). The getenv()
call is how you can get to it.
char *sysDrive = getenv ("SystemDrive");
if (sysDrive == NULL) {
// vote me down.
} else {
// vote me up and use it.
}
if(DWORD len = ::ExpandEnvironmentStrings(input, 0, 0)) {
if(len > 0) {
TCHAR *cp = new TCHAR[len];
if(cp) {
if(::ExpandEnvironmentStrings(input, cp, len) != 0) {
result = string(encodings::utf8, cp);
}
delete[] cp;
}
}
}
相关文章
- Windows 10 安装 FFmpeg 并设置环境变量
- virtual box平台下如何实现Windows和ubuntu的文件共享——涉及增强工具+挂载技巧
- Windows实现内网IPMI端口转发
- Windows 微服务 SpringBoot 启动报错 端口冲突 解决方案
- Windows系统中path环境变量详解
- Windows系统Maven下载 环境变量配置 阿里云镜像配置 本地仓库搭建 开发环境搭建一次解决
- Windows上搭建Standalone模式的Spark环境
- WINDOWS 同步(Interlocked,InterlockedExchangeAdd,Slim读/写锁,WaitForSingleObject,CreateWaitableTimer等等)
- windows下远程连接Mysql
- Windows下一个curl使用
- Windows查看计算机服务监听的端口号
- Linux及Windows系统配置JDK环境变量
- Git for Windows之日志查看与版本切换