News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Application Handle

Started by Robert Collins, January 01, 2005, 07:42:17 AM

Previous topic - Next topic

sluggy

Quote from: Robert Collins on January 01, 2005, 09:02:44 PMI think you answered my question when you stated "the module handle is the actual memory location of the module". I kind of thought that was it but I just wasn't sure.

Thank you. You resolved my curriosity.
You should treat this as coincidental that MS uses the module's base address as its handle, they could change this method anytime in the future. As hutch said, a handle is just a handle, it only has meaning to the functions that know how to use it.

donkey

Hi Sluggy,

The hInstance=Base Address is not really co-incidental, it was done by design and though the label is now meaningless, I doubt it will ever change. This quote is from MSJ...

QuoteFor the sake of convenience, Windows NT and Windows 95 uses the base address of a module as the module's instance handle (HINSTANCE).
...
In Win32, applications don't need to be distinguished from one another because they don't share the same address space. Still, the term HINSTANCE persists to keep continuity between 16-bit Windows and Win32. What's important for Win32 is that you can call GetModuleHandle for any DLL that your process uses to get a pointer for accessing the module's components.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndebug/html/msdn_peeringpe.asp
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable