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
404 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now