Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the application data path in Windows using C++?

I looked all over the internet and there doesn't seem to be a decent solution that I could find. I want to be able to programmatically in C++ obtain the path "%ALLUSERSPROFILE%\Application Data" that explorer can translate into a real path.

Can I do this without relying on third-party code?

like image 945
Brian T Hannan Avatar asked May 24 '10 17:05

Brian T Hannan


People also ask

Where can I find AppData in C drive?

What is the AppData folder? AppData is a hidden folder located in C:\Users\<username>\AppData. The AppData folder contains custom settings and other information needed by applications.

What is app data folder?

The AppData folder contains custom settings and other information that PC system applications need for their operation. It is a hidden folder that includes application settings, files, and data unique to different applications on your computer. This includes all the data specific to your Windows OS user profile.


1 Answers

Use SHGetFolderPath with CSIDL_COMMON_APPDATA as the CSIDL.

TCHAR szPath[MAX_PATH]; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szPath))) {     //.... } 
like image 112
interjay Avatar answered Oct 20 '22 22:10

interjay