HINSTANCE and 1 other semi-related topic.
Aight...I''ve been pondering on how a few things work and was wondering if someone out here knows about it.
Numero 1...how does the HINSTANCE thing work? If I want to know the instance of the program, I mean. Is it a type-casted int that I can just set some variable to or what?
And Numer 2...Is there a way to find out what programs are running (only on the taskbar, but if not, it''s cool ) and in what order they were created. I want this information so I can adjust them when I want my Internet Explorer first on the startmenu after I load it way into the session.
thanks for the possible help!
-Sponge99
"Now watch as I run away in a womanly fashion." - Batman
the HINSTANCE of your program is the instance number assigned to your prog when it starts up by windows and it is used by API''s and external DLL''s
it can be retrived by
HINSTANCE = GetModuleHandle (NULL);
or something like that i dunno cant remember C right now
its just a DWORD thingo
as for getting windows you can use api''s like FindWindow and GetWindowThreadProcessId to access their memory and stuff like that but havnt worked with them much look through an api reference for more info on them
eh?
it can be retrived by
HINSTANCE = GetModuleHandle (NULL);
or something like that i dunno cant remember C right now
its just a DWORD thingo
as for getting windows you can use api''s like FindWindow and GetWindowThreadProcessId to access their memory and stuff like that but havnt worked with them much look through an api reference for more info on them
eh?
eh?
Alright, cool. A DWORD I can deal with.
But I don''t really need to get access to the memory of the programs running...I need a list of what''s running (like in Spy++) and I guess their "ProcessID", and I''m assumming that if I take the minimalists approach and try and set ProcessID''s myself, my computer will kill me, but is that the basic idea or do I need some further reading, hehe...
I''m not even sure if that was clear,
-Sponge99
But I don''t really need to get access to the memory of the programs running...I need a list of what''s running (like in Spy++) and I guess their "ProcessID", and I''m assumming that if I take the minimalists approach and try and set ProcessID''s myself, my computer will kill me, but is that the basic idea or do I need some further reading, hehe...
I''m not even sure if that was clear,
-Sponge99
"Now watch as I run away in a womanly fashion." - Batman
December 29, 2000 11:16 AM
That''s not quite right. In Win32 an HINSTANCE is a handle to your exe or dll. These handles are only valid within a single process. e.g. If you start two .exe''s then they could both get the same HINSTANCE but no two dll''s within a single process will have the same HINSTANCE. Some API''s use HMODULE instead. HMODULE and HINSTANCE are basically the same thing.
In 16-bit windows HINSTANCE was actually a handle to an individual instance. But that all changed when things went to seperate memory spaces.
One well known fact that I''m not sure is officially documented anywhere is that an HINSTANCE is a pointer to where the module image is loaded into memory.
-Mike
In 16-bit windows HINSTANCE was actually a handle to an individual instance. But that all changed when things went to seperate memory spaces.
One well known fact that I''m not sure is officially documented anywhere is that an HINSTANCE is a pointer to where the module image is loaded into memory.
-Mike
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement