Just want to say thanks to everybody who helped. Just when I was about to give up Sergey pointed me to code I used incorrectly yesterday, just to have success today :-)
Public Class Form1
<DllImport("user32.dll", EntryPoint:="GetWindowLong")> _
Private Shared Function GetWindowLongPtr32(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="GetWindowLongPtr")> _
Private Shared Function GetWindowLongPtr64(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr
End Function
Public Shared Function GetWindowLongPtr(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr
If IntPtr.Size = 8 Then
Return GetWindowLongPtr64(hWnd, nIndex)
Else
Return GetWindowLongPtr32(hWnd, nIndex)
End If
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim GWL_EXSTYLE As Integer = -20
Dim WS_EX_TOPMOST As IntPtr = 8
Dim notepad As Process = Process.GetProcessesByName("notepad")(0)
Dim hWnd As IntPtr = notepad.MainWindowHandle
Dim notepad2 As New HandleRef(0, hWnd)
Dim Style As IntPtr = GetWindowLongPtr(notepad2, -20)
MsgBox(Style.ToString)
End Sub
End Class