Show a Explorer window process by the text in the title bar on top of a top most Form

  • Thread starter Thread starter Mattia Fanti
  • Start date Start date
M

Mattia Fanti

Guest
Show a Explorer window process by the text in the title bar on top of a top most Form
Hi, as title says, I'm trying to find a way to show a Explorer window process by the text in the title bar on top of a top most Form.

As the topic is not really disussed online, I've been reading some documentation about FindWindow Api and all I can find near to "useful" is:

How to find main window title name of application

how to get the window title of a process

How to get the Title Bar Text by its Process Id


getting the name of a process

How do I get list of Process Names running

Check to see if a process is running

How to get process Owner ID

How to get the title/name of the last active window?

Get Process ID from Window Title



and also

Process.GetProcessesByName Method

Since I am opening the process as

This code
and NOT with Process class, almost all of them are not suitable to be considered for my case. Also, I can't find any that is close to "check if file exist, if yes then open the Explorer window to that specific file", as many of them refer to notepad, while I think the explorer window title and ID changes for every file ( obviously), while "notepad" process, stay "notepad" always.

I also tried BringToFront, but this latter moves a control in front of other controls, but in this case Explorer is not a control, right?

The least I want to do is to

Get a list of active windows & their process names

as It will waiste memory and time usage for no reason as then I will need to "filter" process to find my process.

I started with:






Imports System.Runtime.InteropServices

Public Class Form1
<DllImport("user32.dll", EntryPoint:="FindWindowW")>
Public Shared Function FindWindowW(<MarshalAs(UnmanagedType.LPTStr)> ByVal lpClassName As String, <MarshalAs(UnmanagedType.LPTStr)> ByVal lpWindowName As String) As IntPtr
End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim hWnd As IntPtr = FindWindowW("TheClassName", Nothing)
If hWnd <> IntPtr.Zero Then
'do whatever you need with the window handle....
End If
End Sub
End Class






I'm really confused about it. Hope someone can assist me on this, I appreciate any Idea.

Thanks

Continue reading...
 
Back
Top