Mega Code Archive

 
Categories / VB.Net Tutorial / Windows
 

DllImport

Option Strict On Imports System.Runtime.InteropServices Imports System.Text Public Module Tester    <DllImport("User32.dll", EntryPoint:="MessageBox", ExactSpelling:=False, CharSet:=CharSet.Unicode)> _    Private Function MessageBox (ByVal hWnd As IntPtr, ByVal lpText As String, byVal lpCaption As String, ByVal uType As UShort) As Short    End Function    <DllImport("Kernel32.dll", EntryPoint:="GetSystemDirectory", ExactSpelling:=False, CharSet:=CharSet.Unicode)> _    Private Function GetSystemDirectory(ByVal lpBuffer As StringBuilder, _            ByVal nSize As Integer) As Integer    End Function    Const MB_OK As Integer = &H0    Const MAX_PATH As Integer = 260    Public Sub Main()       Dim caption As String = "System Directory"       Dim buffer As New StringBuilder(MAX_PATH)       GetSystemDirectory(buffer, MAX_PATH)       MessageBox(Nothing, buffer.ToString(), caption, MB_OK)    End Sub End Module