Pregunta

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.

¿Fue útil?

Solución 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/

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top