views:

71

answers:

1

Hello!

I am now working on a some sort of a game engine and I had an idea to put everything engine-related into a static library and then link it to my actual problem.

Right now I achieved it and actually link that library and every functions seem to work fine, except those, which are windows-related.

I have a chunk of code in my library that looks like this:

   hWnd = CreateWindow(className, "Name", WS_OVERLAPPED | WS_CAPTION | WS_EX_TOPMOST,
              0, 0, 
              800, 600,
              NULL, NULL, GetModuleHandle(NULL), this);

   if (hWnd) {
      ShowWindow(hWnd, SW_NORMAL);
      UpdateWindow(hWnd);
   } else {
      MessageBox(NULL, "Internal program error", "Error", MB_OK | MB_ICONERROR);
      return;
   }

When this code was not in the library, but in the actual project, it worked fine, created the window and everything was ok. Right now (when I'm linking to my library that contains this code) CreateWindow(...) call returns NULL and GetLastError() returns "Operation succesfully completed" (wtf?).

Could anybody help me with this? Is it possible to create a window and display it using a static library call and why could my code fail?

Thank you.

+3  A: 
dreamlax
This is only relevant to DLLs.
Hans Passant