problem with glut concerning resources

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 ??

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);


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.

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

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.

int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInstance,LPSTR lpCmpLine,int nShowCmd);

the instance is passed a paramater to winmain apon entry…

… but the problem occurs when you don’t have a WinMain() entry point in your code.