[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 <assert.h>
#include <iostream>
#include <stdio.h>
#include "wx/stdpaths.h"
#include <Windows.h>
#include <shlobj.h>

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




  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Peter(阿斯拉达)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值