I am learning on how to use API function: GetWindowRect to get the location and size of an external program. But the following error occur when I execute it.
Can anybody kindly tell me why this error occur and how to solve it?
Ive simplified my code (see code below) and test on a normal form instead of getting the location and size of an external program. When u execute it, you should get the same error as below.
Thank you.
Error:
An unhandled exception of type System.NullReferenceException occurred in MeasureLink.exe
Additional information: Object reference not set to an instance of an object.
Can anybody kindly tell me why this error occur and how to solve it?
Ive simplified my code (see code below) and test on a normal form instead of getting the location and size of an external program. When u execute it, you should get the same error as below.
Thank you.
Error:
An unhandled exception of type System.NullReferenceException occurred in MeasureLink.exe
Additional information: Object reference not set to an instance of an object.
Code:
Public Declare Sub GetWindowRect Lib "user32" (ByVal hWnd As IntPtr, ByVal lpRect As RECT)
Public Structure RECT
Public Left As Long
Public Top As Long
Public Right As Long
Public Bottom As Long
End Structure
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim m_rect As RECT
GetWindowRect(Me.Handle, m_rect)
End Sub