VB.NET使用API技巧讲解

来源:互联网 发布:matlab矩阵绝对值 编辑:程序博客网 时间:2024/04/30 15:08

  可能说VB.NET是一个令人恨又令爱的编程软件,新版的。NET不像VB6那样多的支持API调用,好不容易在MSDN中找到的VB.NET使用API,代码如下:.net培训公司

  [Visual Basic]

  SetLastError := True,

  CharSet := CharSet.Unicode, _

  ExactSpelling := True, _

  CallingConvention := CallingConvention.StdCall)> _

  Public Shared Function MoveFile(src As String, dst As String)

  As Boolean

  Leave function empty - DLLImport attribute forces calls to MoveFile to

  be forwarded to MoveFileW in KERNEL32.DLL

  End Function

  这是调用Kernel中的MoveFile函数,在DllImport中必须声明要调用的函数库明,如Kernel32,User32,GDI32等,EntryPoint为要调用函数名。

  下面是调用ShowWindow函数的实例:

  SetLastError:=True,

  CharSetCharSet:=CharSet.Unicode, _

  ExactSpelling:=True, _

  CallingConventionCallingConvention:=CallingConvention.StdCall)> _

  Public Shared Function ShowWindow(ByVal HWNE As Integer,_

  ByVal nCmdShow As Integer)

  As Integer

  End Function

  顺便说一句,在。NET中使用从前VB6中HWND属性的方法是:

  Me.Handle.ToInt32

  上海阜和进修学校

0 0
原创粉丝点击