場景:
1.wxStandardPaths 用來獲取各種系統路徑,可以用於存放app的配置數據。比如文檔目錄,appData等。
代碼:
#include "wx/wxprec.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "wx/cmdline.h" #include "wx/app.h" #include #include#include #include "wx/stdpaths.h" #include #include using namespace std; void TestStandardPaths() { cout << "TestStandardPaths" << endl; wxStandardPaths& sp = wxStandardPaths::Get(); cout << "GetAppDocumentsDir (): " << sp.GetAppDocumentsDir() << endl; cout << "GetDataDir (): " << sp.GetDataDir() << endl; cout << "GetDocumentsDir (): " << sp.GetDocumentsDir() << endl; cout << "GetExecutablePath (): " << sp.GetExecutablePath() << endl; cout << "GetLocalDataDir(): " << sp.GetLocalDataDir() << endl; cout << "GetPluginsDir(): " << sp.GetPluginsDir() << endl; cout << "GetResourcesDir(): " << sp.GetResourcesDir() << endl; cout << "GetTempDir(): " << sp.GetTempDir() << endl; cout << "GetUserDataDir(): " << sp.GetUserDataDir() << endl; cout << "MSWGetShellDir(): " << sp.MSWGetShellDir(CSIDL_APPDATA) << endl; } int main(int argc,char* argv[]) { wxInitialize(); wxEntryStart(argc,argv); wxInitAllImageHandlers(); TestStandardPaths(); wxEntryCleanup(); wxUninitialize(); return 0; }
輸出:
TestStandardPaths GetAppDocumentsDir (): C:\Users\Admin\Documents GetDataDir (): E:\workspace\test_project\01.test_project\test_wx\test_wxCmdLineP arser\msw\Debug\Bin GetDocumentsDir (): C:\Users\Admin\Documents GetExecutablePath (): E:\workspace\test_project\01.test_project\test_wx\test_wx CmdLineParser\msw\Debug\Bin\test_wxCmdLineParser.exe GetLocalDataDir(): E:\workspace\test_project\01.test_project\test_wx\test_wxCmdL ineParser\msw\Debug\Bin GetPluginsDir(): E:\workspace\test_project\01.test_project\test_wx\test_wxCmdLin eParser\msw\Debug\Bin GetResourcesDir(): E:\workspace\test_project\01.test_project\test_wx\test_wxCmdL ineParser\msw\Debug\Bin GetTempDir(): C:\Users\Admin\AppData\Local\Temp GetUserDataDir(): C:\Users\Admin\AppData\Roaming\test_wxCmdLineParser MSWGetShellDir(): C:\Users\Admin\AppData\Roaming