Hello
I'm getting the error "Declaratio n expected" twice in this code...
..it errors at GetSystemDirect ory and msgbox
I thought it may need another imports statement, not sure
I'm using VB.net 2008 express
I'm getting the error "Declaratio n expected" twice in this code...
Code:
'Required in all cases when calling API functions
Imports System.Runtime.InteropServices
'Required in this example and any API function which
'use a string buffer. Provides the StringBuilder class
Imports System.Text
Public Class Form1
<DllImport("KERNEL32.DLL", EntryPoint:="GetSystemDirectoryW", _
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function GetSystemDirectory(ByVal Buffer _
As StringBuilder, ByVal Size As Integer) As Long
' Leave function empty - DLLImport attribute
' forces calls to GetSystemDirectory to
' be forwarded to GetSystemDirectory in KERNEL32.DLL
End Function
Public Const MAX_PATH As Integer = 256
'How to call the API function:
Dim s As New StringBuilder(MAX_PATH)
GetSystemDirectory(s, MAX_PATH)
msgbox(s.ToString(), , "System Directory")
End Class
I thought it may need another imports statement, not sure
I'm using VB.net 2008 express
Comment