手机号登录
手机号重置密码
只需一步,快速开始
管理员
2万
41
1171
#include <windows.h> #include <shlobj.h> #include <filesystem> #include <iostream> int main(void) { std::filesystem::path path; PWSTR path_tmp; /* Attempt to get user's AppData folder * * Microsoft Docs: * https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath * https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid */ auto get_folder_path_ret = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &path_tmp); /* Error check */ if (get_folder_path_ret != S_OK) { CoTaskMemFree(path_tmp); return 1; } /* Convert the Windows path type to a C++ path */ path = path_tmp; /* Free memory :) */ CoTaskMemFree(path_tmp); std::cout << path << std::endl; return 0; }
TCHAR appdata[MAX_PATH] = {0}; SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, appdata);
收藏0回复 显示全部楼层 道具 举报 打印
初级会员
回复 显示全部楼层 道具 举报 打印
所发布的原创教程数量大于10篇
为论坛做出的贡献,不是常人所能达到的!为论坛美化和运营付出辛勤的汗水!
小黑屋|手机版|站务邮箱|学逆向论坛 ( 粤ICP备2021023307号 )|网站地图
GMT+8, 2024-12-31 02:05 , Processed in 0.142329 second(s), 44 queries .
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.