Windows API 第二篇 SHGetSpecialFolderPath
BOOL SHGetSpecialFolderPath( HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);
参数解释:
hwndOwner:Handle to the owner window the client should specify if it displays a dialog box or message box.
lpszPath:Pointer to a null-terminated string that receives the drive and path of the specified folder. This buffer must be at least MAX_PATH characters in size
nFolder:A CSIDL that identifies the folder of interest. If a virtual folder is specified, this function will fail.
fCreate:Indicates if the folder should be created if it does not already exist. If this value is nonzero, the folder will be created. If this value is zero, the folder will not be created.
一个简单的test
建立控制台程序:
#include "stdafx.h"
#include <Windows.h>
#include <string>
#include <Shlobj.h> using namespace std;; int _tmain(int argc, _TCHAR* argv[])
{
WCHAR szPath[MAX_PATH + 1] = { 0 };
wstring strMsgW; BOOL bRet;
//严格一点,每个返回值要判断
bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_PROGRAM_FILES, FALSE);
strMsgW.append(L"CSIDL_PROGRAM_FILES: ");
strMsgW.append(szPath);
strMsgW.append(L"\r\n"); bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_PROGRAM_FILES_COMMON, FALSE);
strMsgW.append(L"CSIDL_PROGRAM_FILES_COMMON: ");
strMsgW.append(szPath);
strMsgW.append(L"\r\n"); bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_SYSTEM, FALSE);
strMsgW.append(L"CSIDL_SYSTEM: ");
strMsgW.append(szPath);
strMsgW.append(L"\r\n"); bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_STARTUP , FALSE);
strMsgW.append(L"CSIDL_STARTUP: ");
strMsgW.append(szPath);
strMsgW.append(L"\r\n"); bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA , FALSE);
strMsgW.append(L"CSIDL_APPDATA: ");
strMsgW.append(szPath);
strMsgW.append(L"\r\n"); MessageBox(NULL, strMsgW.c_str(), L"SHGetSpecialFolderPath Test", MB_OK); return 0;
} 运行结果:

Windows API 第二篇 SHGetSpecialFolderPath的更多相关文章
- Windows API 25篇 TerminateProcess
导语:结束一个进程的方法通常有:exit(), ExitProcess, TerminateProcess. 通常一个进程在正常情况下结束的话,系统会调用 ExitProcess函数结束进程,但有时候 ...
- windows API 第九篇 _tcslwr _strlwr _wcslwr _mbslwr
将字符串转化为小写Convert a string to lowercase. 函数原型: char *_strlwr( char *string ); //#include ...
- Windows API 23 篇 WTSQuerySessionInformation
函数原型:BOOLWINAPIWTSQuerySessionInformationW( IN ...
- [C#] 软硬结合第二篇——酷我音乐盒的逆天玩法
1.灵感来源: LZ是纯宅男,一天从早上8:00起一直要呆在电脑旁到晚上12:00左右吧~平时也没人来闲聊几句,刷空间暑假也没啥动态,听音乐吧...~有些确实不好听,于是就不得不打断手头的工作去点击下 ...
- C#调用windows API的一些方法
使用C#调用windows API(从其它地方总结来的,以备查询) C#调用windows API也可以叫做C#如何直接调用非托管代码,通常有2种方法: 1. 直接调用从 DLL 导出的函数. 2. ...
- [转]Android开源项目第二篇——工具库篇
本文为那些不错的Android开源项目第二篇--开发工具库篇,主要介绍常用的开发库,包括依赖注入框架.图片缓存.网络相关.数据库ORM建模.Android公共库.Android 高版本向低版本兼容.多 ...
- 【OpenGL】第二篇 Hello OpenGL
---------------------------------------------------------------------------------------------------- ...
- Android开源项目第二篇——工具库篇
本文为那些不错的Android开源项目第二篇——开发工具库篇,**主要介绍常用的开发库,包括依赖注入框架.图片缓存.网络相关.数据库ORM建模.Android公共库.Android 高版本向低版本兼容 ...
- 第二篇 SQL Server安全验证
本篇文章是SQL Server安全系列的第二篇,详细内容请参考原文. 验证是检验主体的过程.主体需要唯一标识,那样SQL Server可以确定主体有哪些权限.正确的验证是提供安全访问数据库对象的必要的 ...
随机推荐
- Python自学:第四章 在for循环结束后执行一些操作
# -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(ma ...
- Java Collection - HashMap
HashMap源码解析 java.util.HashMap 类 https://www.cnblogs.com/ysocean/p/8711071.html HashMap线程不安全的原因 https ...
- Django项目:堡垒机(Linux服务器主机管理系统)--02--02堡垒机设计后台交互程序
#main.py #本文件写所有的连接交互动作程序 #————————————————02堡垒机设计后台交互程序 开始———————————————— from django.contrib.auth ...
- 关于css布局的定位问题
虽然职位说是PHP程序,但实际上什么都要做些,排版当然也免不了了,以前自己做网站时就能排出网页了,但是很多东西不系统,有点走马观花,例如关于这个css布局定位的问题就是,今天特意总结了一下,知识这东西 ...
- 如何解决nodemon运行报错问题
原因 nodemon没有被正确安装 解决方法 如果yarn global add nodemon --verbose安装没用的话,然后输入npm i nodemon -g --verbose使用NPM ...
- php开发面试题---php面试题英语(How do you debug a PHP application)
php开发面试题---php面试题英语(How do you debug a PHP application) 一.总结 一句话总结: xdebug or use die() do it; 1.Whi ...
- SpringBoot-application:application.yml/配置文件详解
ylbtech-SpringBoot-application:application.yml/配置文件详解 springboot采纳了建立生产就绪spring应用程序的观点. Spring Boot优 ...
- iOS疑问
1.__NSFrozenDictionaryM在数组类簇中是什么角色?
- day 72 Django基础七之Ajax
Django基础七之Ajax 本节目录 一 Ajax简介 二 Ajax使用 三 Ajax请求设置csrf_token 四 关于json 五 补充一个SweetAlert插件(了解) 六 同源策略与 ...
- Ubuntu Error: No module named 'apt_pkg' 怎么办?
版权声明:任何博客都可以转载,但必须标注来源 https://blog.csdn.net/nikoong/article/details/79612615 ubuntu经常用要添加PPA源,就是使用如 ...