Q:

Why CreateWindowEx returns NULL when using WNDCLASSEX and RegisterClassEx?

So this is like the code from docs.microsoft but I decided to use WNDCLASSEX and RegisterClassEx instead. When running, the app closes itself inmediately and no window is showed. When Debugging I found out that the CreateWindowEx function returns a NULL value. Note that if I use WNDCLASS and RegisterClass, CreateWindowEx returns a normal value an it shows the window as intended.
What does WNDCLASSEX and RegisterClassEx do in comparisson to WNDCLASS and RegisterClass and how this affects CreateWindowEx? I would like to understand the reason of this behavior. 
This is the code. Thanks a lot in advanced!
#ifndef UNICODE
#define UNICODE
#endif

#include <Windows.h>

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

int WINAPI wWinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    PWSTR pCmdLine,
    int nCmdShow)
{
    // Register the windows class.
    const wchar_t CLASS_NAME[] = L"Sample Window Class";

    WNDCLASSEX wc = {};

    wc.lpfnWndProc = WindowProc;
    wc.hInstance = hInstance;
    wc.lpszClassName = CLASS_NAME;

    RegisterClassEx(&wc);

    // Create the window.

    HWND hwnd = CreateWindowEx(
        0,                                                  // Optional window styles.                  
        CLASS_NAME,                                         // Window class
        L"Sorting Algorithm Simulator",                     // Window name
        WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU,           // Window style

        // position and size
        400, 200, 640, 480,

        NULL,       // Parent window                
        NULL,       // Menu
        hInstance,  // Instance handle
        NULL        // Additional application data
    );

    if (hwnd == NULL)
    {
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);

    // Run the message loop.

    MSG msg = {};
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return 0;
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM  lParam)
{
    switch (uMsg)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;

    case WM_PAINT:
    {
        PAINTSTRUCT ps;
        HDC hdc = BeginPaint(hwnd, &ps);

        FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW + 1));

        EndPaint(hwnd, &ps);
    }
    return 0;
    }
    return DefWindowProc(hwnd,uMsg,wParam,lParam);
}

A:

Add 
wc.cbSize = sizeof wc;

and zero out the rest of the structure.

A:

RegisterClassEx() needs to know the size of the structure you are using, so you have to initialize the member wc.cbSize with sizeof(wc):
wc.cbSize = sizeof(wc);

Or equivalently:
wc.cbSize = sizeof(WNDCLASSEX) ;

