2014-04-25 66 views
0

我正在將一個巨大的項目從Qt 4.x遷移到5,(事實上,我在這裏多次請求幫助,我不能更感激您的幫助)。 我得到了一個錯誤:'SHGFP_TYPE_CURRENT'未在此範圍內聲明

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

它沒有什麼太大的意義,因爲我已經包含了正確的頭,這裏有所有的包括:

#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 

這裏是一段代碼這使得使用SHGFP_TYPE_CURRENT的:

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

我研究和一切按http://msdn.microsoft.com/en-us/library/bb762181%28VS.85%29.aspx
是正確的我試圖找到具有相同問題的其他人,但環境不同或問題未得到解答。
謝謝。

回答

0

做更多的研究,我找到了答案,這是與CSIDL_INTERNET_CACHE更換SHGFP_TYPE_CURRENT,我做到了,它編譯,但是我不知道這是否將是相同的(我還沒有寫這個程序,我只是遷移它),所以如果任何人都可以提供一些見解,這將是很好的。

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

+0

鏈接是死:( – sergiol

+0

鏈接已經死了;通過谷歌緩存的版本替換 – sergiol

3

ShlObj.h是這樣定義SHFGP_TYPE_CURRENT

#if (_WIN32_IE >= 0x0500) 

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

#endif 

所以一個能做到這一點:

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

或者另一種方式是直接利用價值01作爲參數SHGetFolderPath