PDA

View Full Version : Any Win32 programmers here?


Radii
09-05-2005, 02:23 PM
I've read through some tutorials and am getting a basic understanding on simple window creation and stuff like that, but the list of APIs is pretty overwhelming. My direct question is this:

How do I go through the process list and find the handle of an application that's running that's not a parent/child of my process? Can I, for example, find out if notepad is running and pull the text that's been typed out of the notepad window, and move that window around, if my appilcation wasn't the one that opened it.

And my general question:

Is there a good overview of the win32 APIs available specificlly in GDI32 and user32 with examples of how to use them all out on the web somewhere? Preferably somewhere not in VB, but I can translate if I have to just to see them in use I guess, I found a site w/ a listing of all of them but just code samples, in VB, without a serious description of what each API call does.


Thanks!

gstelmack
09-05-2005, 04:41 PM
http://www.amazon.com/exec/obidos/tg/detail/-/157231995X/qid=1125956140/sr=8-1/ref=pd_bbs_1/104-7859293-0387155?v=glance&s=books&n=507846

http://www.amazon.com/exec/obidos/tg/detail/-/1572319968/qid=1125956208/sr=1-8/ref=sr_1_8/104-7859293-0387155?v=glance&s=books

But beyond that, "FindWindow" is the key API you want to get the NotePad window. This is what I use in FOFExtractor to get the FOF windows, make selections, press buttons in it, etc. WinSpector (http://www.gipsysoft.com/) is a great tool for finding info out about windows on your system, control IDs, etc.

gstelmack
09-05-2005, 04:42 PM
Oh, and I almost forgot. For code samples, try http://www.codeproject.com

oliegirl
09-05-2005, 05:00 PM
"Great - you rock...outloud"...OK, he didn't really say that but I figured this was a good opportunity to make radii look like a dork :)

Radii
09-05-2005, 08:08 PM
But beyond that, "FindWindow" is the key API you want to get the NotePad window. This is what I use in FOFExtractor to get the FOF windows, make selections, press buttons in it, etc. WinSpector (http://www.gipsysoft.com/) is a great tool for finding info out about windows on your system, control IDs, etc.


Wow WinSpector is awesome. I'd looked at the two books, I'll pick up the first one now that I've seen it recommended :) The second one... is it out of print or something? List Price: $55, Actual price: $170+

gstelmack
09-06-2005, 08:48 AM
That sucks if the second one is now out of print. It's a great intro to threads, processes, and all the nitty-gritty details. But the Petzold book is your best introduction to Win32 programming (I also highly recommend his C# book for an intro to C# and .NET programming).

Surtt
09-06-2005, 11:06 AM
How do I go through the process list and find the handle of an application that's running that's not a parent/child of my process? Can I, for example, find out if notepad is running and pull the text that's been typed out of the notepad window, and move that window around, if my appilcation wasn't the one that opened it.



To answer your question, I don't think you can.

The clipboard was developed to transfer data like this.
If you launch notepad from with in your app you could log the key strokes or use notepad as a "COM" app.
But I don't know how to hijack an independent running app (easily any way).

gstelmack
09-06-2005, 11:09 AM
If all he wants to do is grab the text, you grab a pointer to the Edit Control and ask for its text (this is how I get Player Names in Extractor).

If you want to move the Window around, you can call one of the SetWindowPos commands (there are like a dozen, and no I never remember which one does which) to move it.

It's all about getting Window handles and discovering control IDs, which WinSpector is great for.

Castlerock
09-06-2005, 11:23 AM
I was going to point you to Petzold and Richter but gstelmack already did. For Win32, those two are THE essential reference books.

Radii
09-06-2005, 11:24 AM
It's all about getting Window handles and discovering control IDs, which WinSpector is great for.


Is that something you're able to do programmatically and dynamically without WinSpector once you've done a little background research using it? I may not be asking the right question there, as I'm a long ways away from getting to that point, I think.

gstelmack
09-06-2005, 11:31 AM
Is that something you're able to do programmatically and dynamically without WinSpector once you've done a little background research using it? I may not be asking the right question there, as I'm a long ways away from getting to that point, I think.
No. I use WinSpector to figure out what the control IDs, etc are, then programmatically grab handles to those controls. MFC is nice for this, because instead of using the raw Win32 API you can get a pointer to a CWnd class or a CButton class or whatever and use its methods to pull data or do things.

Source code for FOFExtractor is at my site http://dynamic.gamespy.com/%7Efof/forums/images/smilies/wink.gif

Radii
09-06-2005, 12:22 PM
Source code for FOFExtractor is at my site

you are my hero, even if you coach NC State.