初学者 C++来自 MSDN 问题的 Windows D2D1Circle 示例

发布于 2024-11-01 02:33:47 字数 429 浏览 3 评论 0原文

因此,我只是在 MSDN 上浏览基本的 Windows 编程指南,并尝试执行模块 3 中的 D2D1Circle 示例。我遇到的问题是 VC++ 2008 抛出的错误。 “‘CreateWindowExA’:无法将参数 2 从‘PCWSTR’转换为‘LPCSTR’”

因此,我认为在输入代码时犯了一个小错误,我下载了示例代码 rar 并打开它,它抛出了完全相同的错误。关于如何解决这个问题的任何想法,以便它能够发挥作用。另外,我在 x64 位机器上编程与它无法工作有什么关系吗?我知道指针携带不同大小的值,具体取决于机器,并且被调用的参数都是指针。

更新@ Jollymorphic:在前几个模块中,MSDN 教程说确实没有任何理由继续使用 ascii,因为 unicode 涵盖了 ascii 并且还支持所有其他语言,如中文、日语等。不会实现您的解决方案导致我的程序只支持ascii,随后不允许支持东亚语言?

So I was just going through the basic Windows Programming guide over at MSDN and attempted to do the D2D1Circle Sample in Module 3. The problem I encountered was an error my VC++ 2008 was throwing.
" 'CreateWindowExA' : cannot convert parameter 2 from 'PCWSTR' to 'LPCSTR'"

So, figuring that I had made a slight error while typing the code in I downloaded the sample code rar and opened it up and it threw the exact same error. Any ideas on how I can fix this so it will work. Also, does the fact that I'm programming on a x64 bit machine have anything to do with why it won't work? I know pointers carry different sized values dependent on the machine and both the parameters being called are pointers.

Update @ Jollymorphic: In the first few modules, the MSDN tutorial was saying that there really isn't any reason to continue using ascii since unicode covers ascii and also supports all other languages like Chinese, Japanese, etc. Wouldn't implementing your solution cause my program to only support ascii and subsequently not allow support for east asian languages?

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

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

发布评论

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

评论(1

溺孤伤于心 2024-11-08 02:33:47

PCWSTR 是指向宽(16 位)字符的指针。 LPCSTR 是指向常规(8 位)字符的指针。您的项目可能设置为基于 UNICODE 字符集生成代码。如果在 Visual Studio 中打开项目的属性,然后导航到“常规”页面,您将看到“字符集”属性。如果当前设置为“使用 Unicode 字符集”,那么您可以将其更改为“使用多字节字符集”,并且您的字符串文字将生成为 8 位字符串。

A PCWSTR is a pointer to wide (16-bit) characters. An LPCSTR is a pointer to regular (8-bit) characters. Your project probably is set to generate code based on the UNICODE character set. If you open the properties for your project in Visual Studio, and then navigate to the "General" page, you'll see a "Character Set" property. If it is currently set to "Use Unicode character set," then you can change it to "Use Multi-Byte character set," and your string literals will be generated as 8-bit character strings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文