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
415 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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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
Course of the Month9 days, 5 hours left to enroll

615 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