I am new to vb.net (framework 4) and visual studio is giving me warnings on the following declarations.
Private Declare Auto Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Auto Function GetWindowText Lib "user32" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As IntPtr) As IntPtr
Private Declare Auto Function keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer) As Boolean
Private Declare Auto Function SendMessage Lib "user32" (ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
Private Declare Auto Function SetForegroundWindow Lib "user32" (ByVal hWnd As IntPtr) As Boolean
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer)
and more importantly how do I find out the correct declaration in future?
I cannot imagine you getting a warning from these declarations. But yes, EnumChildWindows is wrong and impossible to use in a VB.NET program. Fix:
The cch argument of GetWindowText is wrong, it is Integer. The rest are good.
Pinvoke.net is a reasonable decent resource for these declarations. Or you could use the P/Invoke Interop Assistant tool. Neither of them are perfect, only SO is.