nvidia sample causes win32 errors?

I compiled nvidia’s simple render texture example, but I noticed it generates a “ERROR_INVALID_WINDOW_HANDLE” error according to GetLastError();

This is the “bad” code:

    // Initialize some graphics state for the PBuffer's rendering context.
    if (wglMakeCurrent( pbuffer.hdc, pbuffer.hglrc) == FALSE)

I added the 2nd call to wglGetLastError() (a function that calls the win32 GetLastError() function and gives feedback about what the error actually was) so it always checks what the last error was (and clears the last error).

Why does wglMakeCurrent create an error on its first call? If there really was an error why wouldn’t wglMakeCurrent return FALSE? What should I make my application do?

You can get the sample (329k) from here: