Untitled
unknown
plain_text
a year ago
854 B
2
Indexable
Never
#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; }