level 14
张剑冰
楼主
环境是 VS2017
API声明如下:
Friend Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
检查代码编译器报告一个警告如下:
警告 CA1901 如代码中所声明的,P/Invoke 'Module1.NativeMethods.keybd_event(Byte, Byte, Integer, Integer)' 的参数 'dwExtraInfo' 在 64 位 平台上的字节宽度将为 4。这是不
正确的
,因为此 API 的实际本机声明表明该参数在 64 位 平台上的字节宽度应为 8。请参考 MSDN Platform SDK 文档来获取帮助,确定应使用哪种数据类型来代替 'Integer'。 EasyTools E:\工程项目文件\简易小工具\EasyTools\Module1.vb 584
如果把最后一个参数写成 Long ,则仍然会报警告如下:
警告 CA1901 如代码中所声明的,P/Invoke 'Module1.NativeMethods.keybd_event(Byte, Byte, Integer, Long)' 的参数 'dwExtraInfo' 在 32 位 平台上的字节宽度将为 8。这是不正确的,因为此 API 的实际本机声明表明该参数在 32 位 平台上的字节宽度应为 4。请参考 MSDN Platform SDK 文档来获取帮助,确定应使用哪种数据类型来代替 'Long'。 EasyTools E:\工程项目文件\简易小工具\EasyTools\Module1.vb 584
感觉怎么改都是警告,但是代码运行倒是没问题,我是不是应该忽略这个警告??
2022年06月29日 06点06分
1
API声明如下:
Friend Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
检查代码编译器报告一个警告如下:
警告 CA1901 如代码中所声明的,P/Invoke 'Module1.NativeMethods.keybd_event(Byte, Byte, Integer, Integer)' 的参数 'dwExtraInfo' 在 64 位 平台上的字节宽度将为 4。这是不
正确的
,因为此 API 的实际本机声明表明该参数在 64 位 平台上的字节宽度应为 8。请参考 MSDN Platform SDK 文档来获取帮助,确定应使用哪种数据类型来代替 'Integer'。 EasyTools E:\工程项目文件\简易小工具\EasyTools\Module1.vb 584
如果把最后一个参数写成 Long ,则仍然会报警告如下:
警告 CA1901 如代码中所声明的,P/Invoke 'Module1.NativeMethods.keybd_event(Byte, Byte, Integer, Long)' 的参数 'dwExtraInfo' 在 32 位 平台上的字节宽度将为 8。这是不正确的,因为此 API 的实际本机声明表明该参数在 32 位 平台上的字节宽度应为 4。请参考 MSDN Platform SDK 文档来获取帮助,确定应使用哪种数据类型来代替 'Long'。 EasyTools E:\工程项目文件\简易小工具\EasyTools\Module1.vb 584
感觉怎么改都是警告,但是代码运行倒是没问题,我是不是应该忽略这个警告??