View Poll Results: what do you think of this probelm?
- Voters
- 2. You may not vote on this poll
-
solution guaranteed
-
solution possible
-
kinda possible
-
impossible
-
Sep 27th, 2001, 05:27 AM
#1
Thread Starter
Member
Windows Task Manager
Hey guys!
well can neone tell me how can i teract with the windows task manager in win NT or when we use Ctrl-Alt-Del in 95/98 to get information about what all applications are running?
Ne help is higly appriciated
AmPrat
-
Sep 27th, 2001, 06:04 AM
#2
Junior Member
Try this.....
Create a new standard project..
Add a listbox and a command button (leave the names default)
Add the following code to the form:
Private Sub Command1_Click()
Dim vCaps As Variant
Dim lIndex As Long
vCaps = GetAllCaptions()
List1.Clear
For lIndex = 0 To UBound(vCaps)
List1.AddItem vCaps(lIndex)
Next
End Sub
Now create a module...
Add the following code to the module:
Option Explicit
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Private Const WM_GETTEXT = &HD
Private aCaptions() As String
Private lCount As Long
Public Function GetAllCaptions() As Variant
lCount = 0
Call EnumWindows(AddressOf EnumWindowsProc, 0&)
If lCount Then ReDim Preserve aCaptions(lCount - 1)
GetAllCaptions = IIf(lCount, aCaptions, Array())
End Function
Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sBuffer As String * 260
If IsWindowVisible(hwnd) Then
ReDim Preserve aCaptions(lCount)
aCaptions(lCount) = Left(sBuffer, SendMessage(hwnd, WM_GETTEXT, 260, ByVal sBuffer))
If Len(Trim(aCaptions(lCount))) Then lCount = lCount + 1
End If
EnumWindowsProc = hwnd
End Function
-
Sep 27th, 2001, 06:21 AM
#3
Thread Starter
Member
Thanx Man....a li'll bit more required
thanx a lot gibbo .....the code works.....but my problem is a bit more complex.....
the thing is i want my application to be resident in memory(dormant though) and i want it to start executing as soon as Internet Explorer is fired.......
i was planning to get the information about IE from the task manager and then planning to fire my application.......
so in the end
how do i keep my application dormant in memory till IE Fires ?
Ne Suggestions?
Amprat
-
Sep 27th, 2001, 07:32 AM
#4
Junior Member
AmPrat,
I'm not sure!!!
Maybe:
Write a stub app that does not load any forms etc. but waits in memory or checks the enumwindows until it finds IE. Once found, your sub could then load your main App.
I'm not familiar with IE. Can it be customized so that IE starts your app on load??
Some code to try:
Create a new project.
Remove the default form1.
Add a module and insert the following code:
Option Explicit
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Private Const WM_GETTEXT = &HD
Private aCaptions() As String
Private lCount As Long
Public Function GetAllCaptions() As Variant
lCount = 0
Call EnumWindows(AddressOf EnumWindowsProc, 0&)
If lCount Then ReDim Preserve aCaptions(lCount - 1)
GetAllCaptions = IIf(lCount, aCaptions, Array())
End Function
Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sBuffer As String * 260
If IsWindowVisible(hwnd) Then
ReDim Preserve aCaptions(lCount)
aCaptions(lCount) = Left(sBuffer, SendMessage(hwnd, WM_GETTEXT, 260, ByVal sBuffer))
If Len(Trim(aCaptions(lCount))) Then lCount = lCount + 1
End If
EnumWindowsProc = hwnd
End Function
Private Sub Main()
Do
Dim vCaps As Variant
Dim AppName As Variant
vCaps = GetAllCaptions()
For Each AppName In vCaps
If AppName Like "*Microsoft Internet Explorer*" Then
' Load your main App Here instead of message
MsgBox "Microsoft Internet Explorer loaded"
Exit Do
End If
Next
Pause 10
Loop
End Sub
Private Sub Pause(pauseTime As Single)
Dim start As Single
start = Timer ' Set start time.
Do While Timer < start + pauseTime
DoEvents ' Yield to other processes.
Loop
Now set the project startup to be Sub Main:
Start IE and a message should be displayed.
I don't think this is a very goog way to achieve your goal but it's the best way I know how!!
Let me know how you get on.
-
Sep 29th, 2001, 06:45 AM
#5
Thread Starter
Member
Hey Gibbo,
thanx again man....yup the code does work......but only when my application gets focus.......if the focus is on IE (The way i want it) the message is not displayed....it is only displayed when i shift the focus to my window!!!
Ne suggestions?
Amprat
-
Oct 1st, 2001, 07:56 AM
#6
Junior Member
Hmmm
You amy be on your own this one. I'm not to sure!
Let me know if you resolve it though.
Best of luke Gibbo....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|