在WinCE上用C++构造一个LPCWSTR (Zune/ZDK)

发布于 2024-08-29 17:04:35 字数 753 浏览 4 评论 0原文

在 WinCE 6 上构建 LPCWSTR 的好方法是什么?我想在 C# 中找到类似于 String.Format() 的东西。我的尝试是:

OSVERSIONINFO   vi;

memset (&vi, 0, sizeof vi);
vi.dwOSVersionInfoSize = sizeof vi;
GetVersionEx (&vi);

char buffer[50];
int n = sprintf(buffer, "The OS version is: %d.%d", vi.dwMajorVersion, vi.dwMinorVersion);

ZDKSystem_ShowMessageBox(buffer, MESSAGEBOX_TYPE_OK);

ZDKSystem_ShowMessageBox 指的是被黑的 Zunes 的 ZDK,可在以下位置找到: http://zunedevwiki.org

这行代码与消息框调用配合得很好:

ZDKSystem_ShowMessageBox(L"Hello Zune", MESSAGEBOX_TYPE_OK);

我的基本目标是查看在 Zune HD 上运行的 WinCE 的确切版本,以查看哪些功能可用(即是 R2 或更早版本?)。

另外我还没有看到 ZDK 的任何标签,所以如果有更合适的东西请编辑!

What's a good way to construct an LPCWSTR on WinCE 6? I'd like to find something similar to String.Format() in C#. My attempt is:

OSVERSIONINFO   vi;

memset (&vi, 0, sizeof vi);
vi.dwOSVersionInfoSize = sizeof vi;
GetVersionEx (&vi);

char buffer[50];
int n = sprintf(buffer, "The OS version is: %d.%d", vi.dwMajorVersion, vi.dwMinorVersion);

ZDKSystem_ShowMessageBox(buffer, MESSAGEBOX_TYPE_OK);

That ZDKSystem_ShowMessageBox refers to the ZDK for hacked Zunes available at:
http://zunedevwiki.org

This line of code works well with the message box call:

ZDKSystem_ShowMessageBox(L"Hello Zune", MESSAGEBOX_TYPE_OK);

My basic goal is to look at the exact version of WinCE running on a Zune HD to see which features are available (i.e. is it R2 or earlier?).

Also I haven't seen any tags for the ZDK so please edit if something is more fitting!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不即不离 2024-09-05 17:04:35

sprintf 用于窄字符串。 LPCWSTR 是一个 const WCHAR *,因此您需要宽字符和正确的函数。

例如

WCHAR buf[100];
StringCchPrintfW(buf, _countof(buf), L"Hello, world!");

或使用通用文本函数,并使用 UNICODE 进行编译,

TCHAR buf[100];
StringCchPrintf(buf, _countof(buf), _T("Hello, world!"));

(您还可以使用其他函数,例如 _stprintf_sswprintf_s 等)

sprintf is for narrow strings. LPCWSTR is a const WCHAR *, so you need wide characters, and the right function.

E.g.

WCHAR buf[100];
StringCchPrintfW(buf, _countof(buf), L"Hello, world!");

or using generic text functions, and compiling with UNICODE,

TCHAR buf[100];
StringCchPrintf(buf, _countof(buf), _T("Hello, world!"));

(There are other functions you could use, such as _stprintf_s, swprintf_s, etc)

瑾夏年华 2024-09-05 17:04:35
CString buffer;
buffer.Format(_T("The OS version is: %d.%d"), vi.dwMajorVersion, vi.dwMinorVersion);
CString buffer;
buffer.Format(_T("The OS version is: %d.%d"), vi.dwMajorVersion, vi.dwMinorVersion);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文