解决masm与GetEnvironmentString不兼容问题

本文详细介绍了在使用MASM汇编语言过程中遇到与GetEnvironmentStrings API不兼容的问题,分析了问题根源,并提供了解决方案,帮助开发者顺利调用Windows环境变量获取功能。

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

 

Masm32 kernel32.inc 中对GetEnvironmentStrings存在问题

所以当在私用masm编译的时候会出现如下错误提示

LIBCD.lib(a_env.obj) : error LNK2001: unresolved external symbol __imp__GetEnvironmentStrings@0

test.exe : fatal error LNK1120: 1 unresolved externals

 

windows api中大部分api都有两个版本 A 版本和W版本

例如

#ifdef UNICODE

#define MessageBox  MessageBoxW   

#else

#define MessageBox  MessageBoxA

#endif // !UNICODE

GetEnvironmentStrings也存在两个版本

#ifdef UNICODE

#define GetEnvironmentStrings  GetEnvironmentStringsW

#else

#define GetEnvironmentStrings GetEnvironmentStrings

#endif // !UNICODE

但是不知由于什么原因 可能weiruan疏忽所以 GetEnvironmentStringsANSI版本是

GetEnvironmentStrings而不是GetEnvironmentStringsA

但是masm却将其当做GetEnvironmentStringsA来处理的

masm中对其宏定义

GetEnvironmentStringsA PROTO

GetEnvironmentStrings equ <GetEnvironmentStringsA>

所以再使用GetEnvironmentStrings宏的时候找不到GetEnvironmentStrings去替换而是找了GetEnvironmentStringsA 然而GetEnvironmentStringsA是不存在的 所以出现了上述问题

 

解决方案

masm32中的kernel32.inc中的

GetEnvironmentStringsA PROTO

GetEnvironmentStrings equ <GetEnvironmentStringsA>

替换成

GetEnvironmentStrings PROTO

然后使用inc2l.exe工具

E:/Program Files/RadASM/masm32/include>inc2l kernel32.inc命令

将生成的kernel32.lib替换masm32kernel32.lib

OK 问题解决

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值