Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

After getting proces_id at Integer GetWindowThreadProcessId(hwnd, target_process_id) how do I convert back to a process Object

Posted on 2008-10-06
2
Medium Priority
?
417 Views
Last Modified: 2010-04-21
I want to convert process_id As Integer to a Process Object

 Public Function EnumWindowsCallBack(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32
        Dim sSave As String
        Dim target_process_id As Integer
        Dim p As Process

        Dim items(5) As String

        target_process_id = 0
        GetWindowThreadProcessId(hwnd, target_process_id)
        If (target_process_id = 0) Then
            MessageBox.Show("Error finding target process ID")
            Exit Function
        End If

--------------->  Convert target_process_id to Process Object

So I can do thing like p.MainWindowHandle
0
Comment
Question by:vaultworld
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 22654889
Not sure if these are in fact the same values...try:

    Dim p As Process = Process.GetProcessById(target_process_id)

From: http://msdn.microsoft.com/en-us/library/76fkb36k.aspx

    "The process identifier can be viewed in the Processes panel of the Windows Task Manager. The PID column displays the process identifier that is assigned to a process."
0
 
LVL 1

Author Closing Comment

by:vaultworld
ID: 31503622
IDLE MIND, Thanks a ton.  I took a 3 year break on this project and start up again and once again your there to help.  

Kind Regards
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question