Window callback

  • Thread starter Thread starter Hogan's Goat
  • Start date Start date
H

Hogan's Goat

I'm looking to do a callback function to get the ProcID or (better yet) get
the process name or app name of all running apps. I've gotten this code
but it's vb6:
Upon a button click I run the following -

hTask& = Shell(Pgm$, vbNormalFocus)
If hTask& Then
CButt(Index).Enabled = 0
ProcID(Index) = hTask&
End If

In a timer event I run the following -

Timer1.Enabled = 0
hW& = GetForegroundWindow()
If Me.hwnd <> hW& Then
Timer1.Interval = 2000
Timer1.Enabled = -1
Exit Sub
End If

For I% = LBound(ProcID) To UBound(ProcID)
hTask& = ProcID(I%)
If hTask& Then
Call fEnumWindows(hTask&)
If hTask& = 0 Then
ProcID(I%) = 0
CButt(I%).Enabled = -1
End If
End If
Next
Timer1.Interval = 1000
Timer1.Enabled = -1


Any ideas?

Hogan out.
 
Hogan's Goat said:
I'm looking to do a callback function to get the ProcID or (better yet) get
the process name or app name of all running apps. I've gotten this code
but it's vb6:

Have a look at the 'System.Diagnostics.Process' class and its
'GetProcesses' method.
 
Here's a cheerful little earful from Herfried K. Wagner [MVP]:
Have a look at the 'System.Diagnostics.Process' class and its
'GetProcesses' method.

OK, I'm back to revisiting this and maybe I'm dense. The sample under the
GetProcesses method shows a way to return all the running processes, but I
just want to show the name of the running apps.

For example, if I have Outlook, Notepad and IE running, along with a bunch
of other services and stuff, I just want to show Outlook, Notepad and IE
and not all the others. I've looked at the Modules class but it doesn't
seem to have the same interfaces.

Hogan out.
 
Here's a cheerful little earful from Herfried K. Wagner [MVP]:


OK, I'm back to revisiting this and maybe I'm dense. The sample under the
GetProcesses method shows a way to return all the running processes, but I
just want to show the name of the running apps.

For example, if I have Outlook, Notepad and IE running, along with a bunch
of other services and stuff, I just want to show Outlook, Notepad and IE
and not all the others. I've looked at the Modules class but it doesn't
seem to have the same interfaces.

Hogan out.


Dim oProcess As Process
For Each oProcess In System.Diagnostics.Process.GetProcesses
If oProcess.MainWindowTitle <> "" Then
Debug.WriteLine(oProcess.MainWindowTitle)
End If
Next
 
Here's a cheerful little earful from _Andy_:
Dim oProcess As Process
For Each oProcess In System.Diagnostics.Process.GetProcesses
If oProcess.MainWindowTitle <> "" Then
Debug.WriteLine(oProcess.MainWindowTitle)
End If
Next

.... and then use that to populate a dropdown?



Hogan out.
 
Back
Top