0

I want to get the AppData folder path by using the ShGetKnownFolderPath function in C++, which returns the not declared in this scope errpr. I tried alot of other functions like this one SHGetFolderPath, my headers are:

#include <shlobj.h>
#include <iostream>
#include <windows.h>

and the only thing which worked so far is char *appData = getenv("AppData");. I am using Windows 10.

P.S

My question might look like a duplicate, but the answers to those questions didn't help me.

IInspectable
  • 46,945
  • 8
  • 85
  • 181
  • I guess (just guessing) you may have to define some macro to let your compiler use functions that only work with new enough Windows. – MikeCAT Jul 23 '16 at 13:27
  • What type of app is this? Also did you define `WINVER and _WIN32_WINNT`? – Jesse Good Jul 23 '16 at 13:34
  • 2
    You have to spell it correctly, capital S capital H. And you have to set _WIN32_WINNT to at least 0x600 so it knows that you don't try to support an old version that doesn't have this function, like XP. – Hans Passant Jul 23 '16 at 13:50
  • I spelled it correctly, believe me, i am making a console application, using MinGW. – PePePlusPlus Jul 23 '16 at 18:05
  • I read other questions and their answers, but they do not work. It is stated clearly in the question isn't it? – PePePlusPlus Jul 23 '16 at 18:08
  • Sorry if I am being rude, I'm just frustrated. – PePePlusPlus Jul 24 '16 at 18:19
  • 1
    You probably didn't follow the instructions correctly `_WIN32_WINNT` has to be defined ***before*** you include any of the Windows headers. So you either need to put it at the very top of your code file, or perhaps even specify it on the command line. – Cody Gray - on strike Jul 24 '16 at 18:31

0 Answers0