RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
VB.NET使用API技巧讲解

VB.NET作为一个功能强大的开发平台,给开发人员带来了不少的好处。我们今天为大家介绍的是VB.NET使用API的相关技巧,希望能给大家带来一些帮助,提高大家的编写效率,方便大家了解这门语言的应用方式。

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

 
 
 
  1. [Visual Basic]   
  2. SetLastError := True, CharSet
     := CharSet.Unicode, _  
  3. ExactSpelling := True, _  
  4. CallingConvention := 
    CallingConvention.StdCall)> _  
  5. Public Shared Function 
    MoveFile(src As String, dst As 
    String) As Boolean  
  6. ' Leave function empty - 
    DLLImport attribute forces 
    calls to MoveFile to  
  7. ' be forwarded to MoveFileW 
    in KERNEL32.DLL  
  8. End Function 

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

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

 
 
 
  1. SetLastError:=True, CharSet
    CharSet:=CharSet.Unicode, _  
  2. ExactSpelling:=True, _  
  3. CallingConventionCalling
    Convention:=Calling
    Convention.StdCall)> _  
  4. Public Shared Function 
    ShowWindow(ByVal HWNE 
    As Integer,_  
  5. ByVal nCmdShow As Integer) 
    As Integer  
  6. End Function 

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

以上就是对VB.NET使用API的详细介绍。


当前文章:VB.NET使用API技巧讲解
转载注明:http://www.jxjierui.cn/article/dpooojs.html