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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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…

867 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

20 Experts available now in Live!

Get 1:1 Help Now