views:

1308

answers:

2

Hi,

how should I DLLImport thing in VB.NET? Example would be:

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function GetWindowText(ByVal hwnd As IntPtr, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer
End Function

If I put it inside a Class or somewhere else, I get "DLLimport is not defined" I am using VS2008 (pro)

thanks.

+2  A: 

You have to add Imports System.Runtime.InteropServices to the top of your source file.

Alternatively, you can fully qualify attribute name:

<System.Runtime.InteropService.DllImport("user32.dll", _
    SetLastError:=True, CharSet:=CharSet.Auto)> _
Anton Gogolev
A: 
Imports System.Runtime.InteropServices
Luhmann