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
411 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
2 Comments
 
LVL 85

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

831 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