#include <iostream>
#include <Windows.h> using std::cout;
using std::endl; // 获取Windows文件夹的路径
//UINT GetWindowsDirectory(LPTSTR lpBuffer,UINT uSize) //获取systrm32文件夹的路径
//UINT GetSystemDirectory(LPTSTR lpBuffer,UINT uSize) //这两个函数的使用方法很简单,和以前一样有两种方法来确定缓冲区的长度:
//1、Windows定义了一个文件路径的最长长度的常量MAX_PATH(值为260),我们可以用它来建立字符串缓冲区;
//2、给缓冲区传入NULL,调用函数成功后将返回缓冲区的长度。 int main()
{
char* buf = nullptr;
// 调用成功后,返回缓冲区的长度,返回windows文件夹的路径
UINT Size = GetWindowsDirectory(NULL,);
buf = new char [Size];
cout << Size << endl;
if( != GetWindowsDirectoryA(buf,Size))
cout << "WindowsDirectory path is :" << endl << buf << endl;
else
cout << "failed. GetLastError() :" << GetLastError() << endl;
delete buf;
buf = nullptr;
cout << endl; // 调用成功后,返回缓冲区的长度,返回系统路径
Size = GetSystemDirectory(NULL,);
buf = new char [Size];
cout << Size << endl;
if( != GetSystemDirectoryA(buf,Size))
cout << "WindowsDirectory path is :" << endl << buf << endl;
else
cout << "failed. GetLastError() :" << GetLastError() << endl;
delete buf;
buf = nullptr;
cout << endl; system("pause");
return ;
}

【转】:https://blog.csdn.net/liangjisheng/article/details/67642491

GetWindowsDirectoryA and GetSystemDirectory的更多相关文章

  1. C++ GetSystemDirectory()

    关于GetSystemDirectory function,参考:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724373(v ...

  2. OD常用断点

    OD常用断点 很全很全 常用断点 拦截窗口: bp CreateWindow 创建窗口 bp CreateWindowEx(A) 创建窗口 bp ShowWindow 显示窗口 bp UpdateWi ...

  3. 常用汇编命令&&OD命令总结

    汇编32位CPU所含有的寄存器有: 4个数据寄存器(EAX.EBX.ECX和EDX)对低16位数据的存取,不会影响高16位的数据.这些低16位寄存器分别命名为:AX.BX.CX和DX,它和先前的CPU ...

  4. 如何用VB获得Windows各类系统目录

    现在有很多关于如何用VB获得Windows目 录的文章,但大都只讲到如何获得Windows目录和System目录,有时候我们却需要获得像"我的文档"这样的目录("我的文档 ...

  5. OD调试程序经常使用断点大全

    经常使用断点  拦截窗体:  bp CreateWindow 创建窗体  bp CreateWindowEx(A) 创建窗体  bp ShowWindow 显示窗体  bp UpdateWindow ...

  6. Delphi7所使用的WinAPI大全(摘自VCL源码,一共1200个函数)

    经过我整理的,去掉了A和W的重复.虽然没写注释,但以后要一个一个研究.有这些WINAPI就够用了. kernel32 = 'kernel32.dll'; gdi32 = 'gdi32.dll'; us ...

  7. OD调试程序常用断点大全

    常用断点  拦截窗口:  bp CreateWindow 创建窗口  bp CreateWindowEx(A) 创建窗口  bp ShowWindow 显示窗口  bp UpdateWindow 更新 ...

  8. C# Windows API

    API:应用程序接口(API:Application Program Interface)应用程序接口(API:application programming interface)是一组定义.程序及协 ...

  9. Windows API 函数列表 附帮助手册

    所有Windows API函数列表,为了方便查询,也为了大家查找,所以整理一下贡献出来了. 帮助手册:700多个Windows API的函数手册 免费下载 API之网络函数 API之消息函数 API之 ...

随机推荐

  1. Codeforces 362E 费用流

    题意及思路:https://blog.csdn.net/mengxiang000000/article/details/52472696 代码: #define Hello the_cruel_wor ...

  2. Elasticsearch index

    POST/{index}/{type} Elasticsearch自动生成ID,自动生成的 ID 是 URL-safe. 基于 Base64 编码且长度为20个字符的 GUID 字符串. 这些 GUI ...

  3. 配置node 的路由

    配置路由 引入路由中间件 const Router= require('koa-router'); 实例化 const router= new Router(); 配置路由地址 router.use( ...

  4. postgres之清理空间碎片

    postgres=# select * from pg_stat_user_tables where relname = 'test'; -[ RECORD 1 ]-------+---------- ...

  5. postgres服务之加密

    数据中往往会出现一些敏感字段,例如电话,邮箱等,这时候有需求进行加密保存 目前可以实现的方式有两种 方式一:这种方法,aes的加密方法不支持aes-192,不支持aes-256 #使用encrypt加 ...

  6. MariaDB 管理

    在尝试运行MariaDB之前,首先确定其当前状态,运行或关闭. 有三个选项用于启动和停止MariaDB - 运行mysqld(MariaDB脚本). 运行mysqld_safe启动脚本. 运行mysq ...

  7. apue 第19章 伪终端

    伪终端是指对于一个应用程序而言,他看上去像一个终端,但事实上它并不是一个真正的终端. 进程打开伪终端设备,然后fork.子进程建立一个新的会话,打开一个相应的伪终端从设备.复制输入.输出和标准错误文件 ...

  8. Java IO Demo

    //FileReader FileWriter 读写英文    public void FileReaderAndWriter1() throws Exception { File filePath ...

  9. JavaScript 获取时间,时间戳

    一. 动态获取js时间 1.方法一:最简单的写法,直接输出时间到页面 <!DOCTYPE html> <html> <head> <title>< ...

  10. sed 对文件进行操作

    首先我们想不进入一个文件 对文件进行操作 那么久需要用到sed了 在某个变量之前添加内容: sed -i 's/原内容/要添加内容/g' 文件名 sed -i 's/原内容/要添加内容&/' ...