积极答复者
一句C#没看懂什么意思,谁来翻译成VB

问题
-
本身我使用的是VB,今天看到了一句C#语句,没搞懂什么意思.很郁闷,谁来翻译成VB
下面是C#的语句
1 [DllImport("user32.dll", CharSet = CharSet.Auto)] 2 public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
我只明白导入Dll user32.dll 下面的没看懂.
人要诚实!还要踏实!- 已编辑 Dodu.NET 2009年2月6日 10:37
- 已移动 Sheng Jiang 蒋晟Moderator 2009年2月6日 19:01 CLR互操作问题 (从 Visual Basic 移动到 .NET Framework 一般性问题讨论区)
- 已移动 feiyun0112Moderator 2009年2月9日 4:04 VB.NET (从 .NET Framework 一般性问题讨论区 移动到 Visual Basic)
答案
-
Dodu.NET 说:
我试着这样写,不知道对不对,给大家看看.
Declare Function SendMessage Lib "user32.dll" _
(ByVal hWnd As System.IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As System.IntPtr
你这样写也可以,或者:
<DllImport("user32.dll", CharSet := CharSet.Auto)> _
Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function- 已标记为答案 Dodu.NET 2009年2月8日 5:04
-
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Function SendMessage( _
ByVal hWnd As HandleRef, _
ByVal Msg As UInteger, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function
http://feiyun0112.cnblogs.com/- 已标记为答案 Dodu.NET 2009年2月8日 5:04
全部回复
-
Dodu.NET 说:
我试着这样写,不知道对不对,给大家看看.
Declare Function SendMessage Lib "user32.dll" _
(ByVal hWnd As System.IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As System.IntPtr
你这样写也可以,或者:
<DllImport("user32.dll", CharSet := CharSet.Auto)> _
Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function- 已标记为答案 Dodu.NET 2009年2月8日 5:04
-
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Function SendMessage( _
ByVal hWnd As HandleRef, _
ByVal Msg As UInteger, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function
http://feiyun0112.cnblogs.com/- 已标记为答案 Dodu.NET 2009年2月8日 5:04
-
feiyun0112 说:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Function SendMessage( _
ByVal hWnd As HandleRef, _
ByVal Msg As UInteger, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function
http://feiyun0112.cnblogs.com/
我想问明白
其中一个参数你为什么要定义成 handleRef 呢?
ByVal hWnd As HandleRef
人要诚实!还要踏实!- 已标记为答案 Dodu.NET 2009年2月8日 5:04
- 取消答案标记 Sheng Jiang 蒋晟Moderator 2009年2月8日 5:06
-
Dodu.NET 说:feiyun0112 说:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Function SendMessage( _
ByVal hWnd As HandleRef, _
ByVal Msg As UInteger, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function
http://feiyun0112.cnblogs.com/
我想问明白
其中一个参数你为什么要定义成 handleRef 呢?
ByVal hWnd As HandleRef
人要诚实!还要踏实!
6) You can replace "hWnd" with "IntPtr" instead of "HandleRef". However, you are taking a risk in doing this - it may cause your code to crash with race conditions - .NET can and will dispose your window handles out from under your message causing all sorts of nasty problems!
http://pinvoke.net/default.aspx/user32/SendMessage.html
http://feiyun0112.cnblogs.com/