VB.Net中该怎么调用windows的API?
调用API时有的参数为String类型,但是VB.Net中的string类型是unicode编码,而API中的是ASII编码。直接用的话不行。比如FindWindow("...
调用API时有的参数为String类型,但是VB.Net中的string类型是unicode编码,而API中的是ASII编码。直接用的话不行。比如FindWindow("Shell_TrayWnd", " ")这个API,不论怎么调用,返回值都是0.
展开
展开全部
1.Windows的API有两个版本的,比如ANSI的FindWindowA(),Unicode的FindWindowW()
2.两种声明的方式
<DllImport("user32.dll", CharSet:=CharSet.Auto, EntryPoint:="FindWindow")> _
Shared Function FindWindow(ByVal className As String, ByVal windowName As String) As IntPtr
End Function
Declare Auto Function FindWindow Lib "user32.dll" Alias "FindWindow" (ByVal className As String, ByVal windowName As String) As IntPtr
2.两种声明的方式
<DllImport("user32.dll", CharSet:=CharSet.Auto, EntryPoint:="FindWindow")> _
Shared Function FindWindow(ByVal className As String, ByVal windowName As String) As IntPtr
End Function
Declare Auto Function FindWindow Lib "user32.dll" Alias "FindWindow" (ByVal className As String, ByVal windowName As String) As IntPtr
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询