What's an "Instance"...?
I can't seem to understand exactly what an "Instance" is.
You know, like: HINSTANCE hInstance or HINSTNACE hPrevInstance.
I've been passing hInstance (the WinMain parameter) to all
the functions that have a HINSTANCE parameter, but I'm not
exactly sure what a HINSTNACE is.
When would be an example of a time where you'd pass another
HINSTANCE to a function (not WinMain's hInstance)? When would
you create another HINSTANCE variable?
Hi ethic, hope you are well :)
HINSTANCE is the starting/base address of your application as passed to your windows program by WinMain and is itself obtained for passing to WinMain by GetModuleHandle(0) - you can use this fn at any time in the lifetime of your app to get your application's HINSTANCE (HMODULE, the return type of GetModuleHandle is the same thing). WinMain's hPrevInstance is an obsolete term for 16bit backward compatibility; for all practical purposes just ignore it.
You would create or get an instance handle when you wanted to map a dll into your application's address space with eg. LoadLibrary("name of dll"). The HINSTANCE in this case would be the base address for your dll (within your app's address space?)
There may be other scenarios but I think that covers the basics. Fordy, Adrianxw and Novacain will probably be able to give you a more detailed and explicit answer but I hope that has helped some. :)