Untitled
unknown
plain_text
2 years ago
854 B
10
Indexable
#include <iostream>
#include <Windows.h>
std::string GetLocalAppDataPath() {
HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
char path[MAX_PATH];
DWORD pathSize = sizeof(path);
if (RegQueryValueEx(hKey, "Local AppData", nullptr, nullptr, (LPBYTE)path, &pathSize) == ERROR_SUCCESS) {
RegCloseKey(hKey);
return std::string(path);
}
RegCloseKey(hKey);
}
return "";
}
int main() {
std::string localAppDataPath = GetLocalAppDataPath();
if (!localAppDataPath.empty()) {
std::cout << "LOCALAPPDATA path: " << localAppDataPath << std::endl;
} else {
std::cerr << "Failed to retrieve LOCALAPPDATA path." << std::endl;
}
return 0;
}
Editor is loading...