'SHGFP_TYPE_CURRENT' was not declared in this scope

允我心安 提交于 2019-12-23 05:19:06

问题


I am migrating a huge project from Qt 4.x to 5, (in fact I have asked for help several times here, I couldnt be more grateful for your help). I am getting the next error:

..\marssies\userlayerswidget.cpp: In member function 'void LayersModel::importFromOld()': ..\marssies\userlayerswidget.cpp:1736:60: error: 'SHGFP_TYPE_CURRENT' was not declared in this scope

It doesnt make too much sense, as I have the correct header included, here are all the includes:

#include "userlayerswidget.h"
#include "appcommon.h"
#include "messagebox.h"
#include "polyline.h"
#include "painterbar.h"
#include "rectangle.h"
#include "polygon.h"
#include "label.h"
#include "line.h"
#include "point.h"
#include "encsymbol.h"
#include "touchswibz.h"
#include "mapmodulelist.h"
#include "offlinelayersaver.h"
#include "circle.h"

#include <QMenu>
#include <QDir>
#include <QDesktopServices>
#include <QtDebug>

#ifdef _WIN32
#include <Shlobj.h>
#endif

And here is the piece of code that makes use of SHGFP_TYPE_CURRENT:

void LayersModel::importFromOld() {
TCHAR appPath[MAX_PATH];
if (!(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appPath))) {
    //code
}

I have researched and everything is correct according to http://msdn.microsoft.com/en-us/library/bb762181%28VS.85%29.aspx
I tried to find other people with the same problem but either the context was different or the question wasnt answered.
Thankyou.


回答1:


In ShlObj.h is SHFGP_TYPE_CURRENT defined like this:

#if (_WIN32_IE >= 0x0500)

typedef enum {
    SHGFP_TYPE_CURRENT = 0,
    SHGFP_TYPE_DEFAULT = 1,
} SHGFP_TYPE;

#endif 

So one can do this:

#define _WIN32_IE 0x0500
#include <ShlObj.h>

Or another way is to directly use value 0 or 1 as parameter to SHGetFolderPath.




回答2:


Doing more research I found an answer that was to replace SHGFP_TYPE_CURRENT with a literal 0, I did it and it compiled, but I'm not sure if it will be the same (I haven't written this program, I'm just migrating it). So if anybody could give some insight it would be nice.

Source: http://webcache.googleusercontent.com/search?q=cache:http://www.dreamincode.net/forums/topic/200660-undeclared-variable/



来源:https://stackoverflow.com/questions/23286545/shgfp-type-current-was-not-declared-in-this-scope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!