News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Find classname for EnumWindows

Started by Magnum, December 05, 2012, 11:31:31 AM

Previous topic - Next topic

Magnum

How do you find the Classnames for other programs ?


szClassname                 byte            "IEFrame", 0
szFilename                  byte            "iexplore.exe", 0

.data?

we                          WINDOWENTRY32   <>
szCurrentFilename           byte 255 dup    (?)
szCurrentClassname          byte 255 dup    (?)

.code
    Start:

xor ebx, ebx

mov we.lpszClassname, offset szClassname
mov we.lpszFilename, offset szFilename

    invoke EnumWindows, addr EnumFunc, addr we
    invoke ExitProcess, ebx

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

qWord

Quote from: Magnum on December 05, 2012, 11:31:31 AM
How do you find the Classnames for other programs ?
That's not possible (I assume you mean the classname of a window).
You can search for a top level window with FindWindow()  either by Titel, by Calssname or both. From the found window handle you can get the Process ID by using GetWindowThreadProcessId
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

i suppose EnumProcesses, then GetGUIThreadInfo and GetClassName in the callback

i seem to remember something in the old forum   :P

you can google "get window handle from process ID" for clues

qWord

Quote from: dedndave on December 05, 2012, 11:53:38 AM
i suppose EnumProcesses, then GetGUIThreadInfo and GetClassName in the callback

i seem to remember something in the old forum   :P
Interesting solution, but only sense full if you know that the application has only one window. But even in this case, you can commonly determine the class name by using tools like WinSpy++ and then use FindWindow() to get the window handle.(?)
MREAL macros - when you need floating point arithmetic while assembling!

Magnum

qWord,

http://www.masmforum.com/board/index.php?topic=11603.0

Classname must be constant for every program based on the code above.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

qWord

Quote from: Magnum on December 05, 2012, 12:12:55 PM
qWord,

http://www.masmforum.com/board/index.php?topic=11603.0

Classname must be constant for every program based on the code above.

Andy
no it must not. For example you can dynamically create the class name (or atom). Furthermore, there generally no direct link between a window class and a process. A process can have N windows of K classes -> which is the "correct" class in that case?
MREAL macros - when you need floating point arithmetic while assembling!

qWord

Magnum,
maybe misunderstand you: you already have the class name "IEFrame" and/or the image name and you want to enumerate all TLWs and test if their class name and/or the process name match?
In that case, use the window handle in the Enum-Callback with GetClassName() to get the class name. The executable path can be obtained (for example) with GetWindowThreadProcessId() +OpenProcess() and GetProcessImageFileName().

You may describe what you want to do exactly.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

the EnumWindows function only enumerates top-level windows (not child windows/controls)
the callback gives you the main window handle for each program that has a window
from that, you can get the main window classname with GetClassName

so - unless you have some specific reason for using EnumProcesses (process IDs), use EnumWindows

Magnum

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

well, maybe it should - lol

you aren't being clear about what you are trying to accomplish
pretend, for a moment, that you are not Secret Sam, and tell us what you want to do

Quote from: Magnum on December 05, 2012, 11:31:31 AM
How do you find the Classnames for other programs ?

dedndave

sorry, Andy - i shouldn't be so harsh

but - if you use EnumProcesses, the Process ID is passed to the callback routine
generally, i try to avoid the PID and stick with window handles - lol
but - some operations may require it

the simplest way to get the class names for all top-level windows is EnumWindows/GetClassName