By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,660 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,660 IT Pros & Developers. It's quick & easy.

Getting form properties from another running application

P: n/a
I would like to retrieve properties such as position and size of another
application running at the same time as my .NET application. The other
application may or may not be .NET. I understand how to retrieve the handle
and window name, using, eg:

Dim proc() As Process
proc = Process.GetProcessesByName("process_name")
Dim i As System.IntPtr = proc(0).MainWindowHandle()

But I can't work out how to use the handle information to access the other
application's properties from windows.
Sep 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Never mind, I have figured it out using PInvoke and User32.dll. eg.

Private proc() As Process

<DllImport("user32")_
Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef rect As
Rectangle) As Integer

End Function

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
proc = Process.GetProcessesByName("process_name")

Dim i As System.IntPtr = proc(0).MainWindowHandle()

Dim r As Rectangle

GetWindowRect(i, r)

End Sub
Sep 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.