在问我是否已经看到同样的问题和问题in this C# post之前,它会告诉我们在代码分析工具上导致误报的原因,但是没有说明如何解决问题,这就是为什么我和#39; m要求。
我发布了这些API声明:
<DllImport("user32.dll", EntryPoint:="GetWindowLong", CharSet:=CharSet.Auto)>
Friend Shared Function GetWindowLong32(
ByVal hWnd As HandleRef,
<MarshalAs(UnmanagedType.I4)> ByVal nIndex As WindowAttributes
) As Integer
End Function
<DllImport("user32.dll", EntryPoint:="GetWindowLongPtr", CharSet:=CharSet.Auto)>
Friend Shared Function GetWindowLong64(
ByVal hWnd As HandleRef,
<MarshalAs(UnmanagedType.I4)> ByVal nIndex As WindowAttributes
) As Long
End Function
当我通过代码分析工具时,它无法找到GetWindowLongPtr
函数的入口点。
我是VS2013 Ultimate,我正在为x64编译而我已经阅读了this article from MSDN。
有一种正式的方法可以解决这个问题而不会在代码分析工具中抑制错误信息吗?
答案 0 :(得分:1)
这消除了CS消息/标志,但是您必须检查它是否仍然按预期工作(我不能想到测试用例):
<DllImport("user32.dll", EntryPoint:="GetWindowLongA", CharSet:=CharSet.Ansi)>
Friend Shared Function GetWindowLong64(
ByVal hWnd As HandleRef,
<MarshalAs(UnmanagedType.I4)> ByVal nIndex As WindowLongFlags
) As Long
End Function