PDA

View Full Version : problem with glut concerning resources



Tresher
08-07-2002, 01:37 PM
I am using glut and want to combine some data with the exe file. Normally (that means with Win Api) i would try something like 1. hres = LoadResource(hInstance,...
2.pData = LockResource(hres);
Of course the problem is that i dont know how to get the hInstance - handle...but many win api functions need this handle. Is it possible to connect WinMain with GLUT or is there another method to access resources ?
Maybe there is a function that returns me this handle ??
Greetings,Martin

Bob
08-08-2002, 01:50 AM
You can get the hInstance of the module with GetModuleInstance().

Or you can create a regular WinMain in your code (and setup your project to use the WinMain as entry point instead of main, assuming you use MSVC), and then call main from there. No modifications needed, only add this after your existing main function.



... WinMain(...) // don't know the protoype for WinMain
{
// Get hInstance from WinMain here

int argc = 1;
char *argv = "myprogram.exe";
main(argc, &argv);
}

Deiussum
08-08-2002, 04:17 AM
Are you sure it's GetModuleInstance()? MSDN has that function as a method on the CComModule class.

I know there is a Win32 API function that will get the HINSTANCE for you, but I just can't seem to find it right now. If I remember right it was some name that didn't really make sense for what it did.

Bob
08-08-2002, 12:03 PM
Well, was a little bit too fast with the documentation when I looked it up. Seems to be GetModuleHandle() instead.

Here's a piece of code I found in one of my programs.



HINSTANCE instance = GetModuleHandle(NULL);

I hope that one is right http://www.opengl.org/discussion_boards/ubb/smile.gif

Deiussum
08-08-2002, 12:43 PM
Ahh... yes. That is the one! I kept searching for something like GetGlobalModuleHandle or GetGlobalWhatever... I haven't used that API function in a long time and my memory was a bit hazy. http://www.opengl.org/discussion_boards/ubb/smile.gif

no-one
08-08-2002, 04:18 PM
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInstance,LPSTR lpCmpLine,int nShowCmd);

the instance is passed a paramater to winmain apon entry...

Bob
08-09-2002, 01:12 AM
... but the problem occurs when you don't have a WinMain() entry point in your code.