Solved

Get App Name?

Posted on 2003-11-05
9
297 Views
Last Modified: 2010-05-03
how can I get the name of the window/application oppened?
For example if user oppened WINDOWS EXPLORER. then the application will msgbox
WINDOWS EXPLORER OPENED
or whatever...
how can it be done?

thanks for any help
0
Comment
Question by:deathman5
9 Comments
 
LVL 3

Expert Comment

by:NBrownoh
Comment Utility
you could monitor all the windows and when a new one is made you could grab the name from that.  but then your using timers.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 62 total points
Comment Utility
"System Wide Shell Hook Dll (Version 2.0)"
http://www.freevbcode.com/ShowCode.Asp?ID=1308
0
 
LVL 3

Expert Comment

by:NBrownoh
Comment Utility
i swear ive seen that name somewhere, azrasound....  are you around in DC any?
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
No, I live in Houston.  Perhaps from another forum?  Perhaps you listen to house music?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 16

Assisted Solution

by:Richie_Simonetti
Richie_Simonetti earned 32 total points
Comment Utility
Logging use of executables in Windows

This handy little tip can be used to log the use of .exe, .lnk, .pif, .bat, and .com files on your computer. All it needs is a little registry tinkering. Place this code in a module, and set the project startup object to 'Sub Main'

Procedure

Sub Main()
If Command$ <> "" Then
Open "c:\apps\exelog.txt" For Append As #1
Print #1, Command$ & " " & CStr(Now)
Close #1
Call Shell(Command$, vbNormalFocus)
End If
End
End Sub

Registry Changes

The registry changes are:

HKEY_CLASSES_ROOT\exefile\shell\open\command to: "C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\lnkfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\piffile\shell\open\command to: "C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\batfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\comfile\shell\open\command to: "C:\exewrap.exe" "%1" %*

What happens it that instead of running the program directly, Windows calls our program, which logs filename and time, and then calls the program.
 
This code belongs to Allapi.net - Url is no longer available
0
 
LVL 3

Expert Comment

by:NBrownoh
Comment Utility
hehe, i live in ohio, by DC i meant direct connect.  this is going to bug me forever now.

But on to the question,
Are you trying to halt execution of certain programs or did you want to just log what programs are being used?  
0
 

Assisted Solution

by:toddpasley
toddpasley earned 31 total points
Comment Utility
Hi,

I assume you mean a applicaiton you have just executed??? If so, then you have the HWnd

From the Hwnd, you can use GetWindowText WIN API to access the title.

Like....
' Add the following declarations to get window title.
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long


' then use the following code to get the title.
    Dim wincapt As String
 
    'Get the windowtext length
    wincapt = Space$(GetWindowTextLength(hwnd) + 1)
    'get the window text
    GetWindowText hwnd, wincapt, Len(wincapt)
    'remove the last Chr$(0)
    wincapt = Left$(wincapt, Len(wincapt) - 1)

    ' wincapt holds the title of the window with the handle hwnd.
    MsgBox wincapt + " just opened"




If you instead mean that you want to monitor as the user opens stuff rather than your applicaiton... then simply hook into the windows message queue and wait for WM_ACTIVATE or WM_ACTIVATEAPP messages. When one is sent, grab the hwnd and apply the code above.

Hope this helps,

Todd.
0
 
LVL 5

Expert Comment

by:fantasy1001
Comment Utility
I am not sure what are you up to:
This example will list all the windows activate at the time
http://www.thescarms.com/VBasic/alttab.asp

If you want to monitor all the windows a user open using this example, my advice is to use a timer (interval = 1000), and record the difference if new program added to the list.

However, if you already have the hwnd, then it is advisable to use the API GetWindowText & GetWindowTextLength

~ fantasy ~

0
 

Author Comment

by:deathman5
Comment Utility
thx everybody, but Shell Hook Dll was what I wanted :)
But thx 4 anybody how helped
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

10 Experts available now in Live!

Get 1:1 Help Now