日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Windows API 第二篇 SHGetSpecialFolderPath

發布時間:2023/12/19 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Windows API 第二篇 SHGetSpecialFolderPath 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

BOOL SHGetSpecialFolderPath( HWND hwndOwner,
???????????????????????????????? LPTSTR lpszPath,
???????????????????????????????? int nFolder,
???????????????????????????????? BOOL fCreate );

參數解釋:

hwndOwnerHandle to the owner window the client should specify if it displays a dialog box or message box.

lpszPathPointer 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; }運行結果:

?

?

轉載于:https://www.cnblogs.com/priarieNew/p/9753922.html

總結

以上是生活随笔為你收集整理的Windows API 第二篇 SHGetSpecialFolderPath的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。