At some point however a function only allows a HandleRef as a parameter and not the IntPtr. Just go with IntPtr as long the parameters work, and as soon the GetLastError returns a "invalid parameter" error you might have to use a HandleRef instead.
Since API's don't continue until the function completed, a handleref is usually useless. A few functions that require a handleref:
Code:<Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="GetWindowLong")> _ Private Shared Function GetWindowLongPtr32(ByVal hWnd As Runtime.InteropServices.HandleRef, ByVal nIndex As Integer) As Long End Function <Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="GetWindowLongPtr")> _ Private Shared Function GetWindowLongPtr64(ByVal hWnd As Runtime.InteropServices.HandleRef, ByVal nIndex As Integer) As Long End Function Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As System.Runtime.InteropServices.HandleRef, ByRef lpRect As API.WRECT) As Boolean Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As System.Runtime.InteropServices.HandleRef, ByRef lpRect As API.WRECT) As Boolean




Reply With Quote