程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> [wxWidgets]_[初級]_[不常見但實用的類wxStandardPaths]

[wxWidgets]_[初級]_[不常見但實用的類wxStandardPaths]

編輯:C++入門知識

[wxWidgets]_[初級]_[不常見但實用的類wxStandardPaths]



場景:

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




  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved