今天无意中发现可以替代VB中的Any 在API声明中可以使用<MarshalAs(UnmanagedType.AsAny)>

VB中声明的API

1 Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)

在vb.net可以这样玩

1 Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, <MarshalAs(UnmanagedType.AsAny)> lParam As Object) As Int32

 

posted on 2016-07-21 16:26  光华工作室  阅读(1591)  评论(0编辑  收藏  举报