Visual C++:error C2664: 'GetModuleFileNameW' : cannot convert parameter 2 from 'char' to 'LPWCH'

本文介绍了在 Windows API 中如何正确调用函数的方法。当使用这些函数时,开发者需要了解它们实际上是宏定义到 ANSI 或 Unicode 版本。文章还解释了如何通过修改项目设置来选择使用多字节字符集或 Unicode 字符集。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A lot of the "functions" of the Windows API are actually macroes to either the ANSI (A) or Unicode (W for wide) version of the function. Depending on your project settings, these macroes will be either DoSomeFunctionA or DoSomeFunctionW when you want to callDoSomeFunction. The portable way would be then to useTCHAR because it is defined aschar for ANSI and wchar_t for Unicode.

If you don't want to compile with Unicode, you can change your project settings toProject Properties -> Configuration Properties -> General -> Character Set -> Use Multibyte Character Set.

If you do want to compile with Unicode, then you should append anA (ex:GetModuleFileNameA) to the necessary function names.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值