繁体   English   中英

Windows Mobile 6.5-读写配置文件的最佳方法

[英]Windows mobile 6.5 - best way to read and write from and to a config file

我有一台运行WM6.5的手持设备,试图将一个应用程序组合在一起,该应用程序会提示用户一些信息(登录名,密码)并将其保存到文件中以备后用。

已经尝试过app.config文件,但不幸的是它需要System :: Configuration,我可以添加DLL但无法运行代码,它需要CRL或类似的东西,但我无法将其配置为移动应用程序-项目/解决方案配置部分缺少必需的选项。

我正在使用Visual Studio 2008 C ++

做到这一点的最佳方法是什么? 准确地说,1)在某个地方写一个字符串,2)稍后再读回来。

TIA

以后编辑:

我尝试使用二进制文件,像这样

// write to config file
std::string s="helloworldhelloworldhelloworld";
ofstream ofile("test.txt",ios::binary);
ofile.write((char*)s.c_str(),strlen(s.c_str()));
ofile.close();

然后我试着像这样读回来

// read config file
char read_str[60];
ifstream inf("test.txt",ios::binary);
inf.read(read_str,60);    
inf.close();

LPCTSTR application_settings = CA2W(read_str);

如果字符串更长,则在字符串末尾添加一些垃圾,否则,则更多。

有没有办法解决此转换问题?

事实证明,项目使用的是Unicode,必须使用wifstream和wofstream才能正确读取字符串,而不是尝试将其从ANSI转换为Unicode。

这应该提醒我将来不要使用强类型语言。 不幸的是,Windows Mobile没有其他重大选择。 花了一个小时的时间,我本可以将这段时间用于其他事情。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM