VB.Net Tutorial/Windows/DLL

Материал из VB Эксперт
Версия от 12:56, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Create DLL library

" Compile from command line with:
"    VBC /t:library Dog.vb
Option Strict On
Public Class Dog
   Private Name As String
   Public Sub New(name As String)
   End Sub
End Class

Use WIN32 Function directly

Option Strict On
Public Module Tester
   Public Declare Unicode Function MessageBox Lib "User32.dll" Alias "MessageBoxW" (ByVal hWnd As IntPtr, ByVal lpText As String, _
          byVal lpCaption As String, ByVal uType As UShort) As Short
   Private Declare Unicode Function GetSystemDirectory Lib "kernel32.dll" Alias "GetSystemDirectoryW" _
           (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
   Private Const MB_OK As Integer = &H0&
   Private Const MAX_LEN As Integer = 256
   Public Sub Main()
      Dim caption As String = "System Directory"
      Dim message As String
      Dim buffer As String = Space(MAX_LEN)
      Dim retChars As Integer
      retChars = GetSystemDirectory(buffer, Len(buffer))
      message = Left(buffer, retChars)
      MessageBox(Nothing, message, caption, MB_OK)
   End Sub
End Module