来自 Charles Petzold 的纯 C 中的 MsgBoxPrintf(win32 api) 提供中文输出...我做错了什么?

MsgBoxPrintf(win32 api) in pure C from Charles Petzold gives Chinese Output...What have i done wrong?

VS2013 社区版 OS:Win7 sp1

#include<Windows.h>
#include<stdio.h>


    //VS2013 Community edidtion OS:Win7 sp1 

    //Using wchar_t for unicode and L"  " for strings

    //The MessageBoxPrintf from the book modified to take wide chars

    int CDECL MsgBoxPrintf(wchar_t *szCaption,const wchar_t *szFormat, ...)
    {
        wchar_t szBuffer[1024];
        va_list pArgsList;
        va_start(pArgsList, szFormat);

     //Using _vsnwprintf_s since _vsntprintf is deprecated   
        _vsnwprintf_s(szBuffer, sizeof(szBuffer)/sizeof(wchar_t), 1024-1, szBuffer, pArgsList);
        va_end(pArgsList);
    //Using MessageBoxW instead of MessageBox
        return MessageBoxW(0, szBuffer, szCaption, 0);
    }

    int
    WINAPI
    WinMain(HINSTANCE hInstance,
            HINSTANCE hPrevInstance,
            PSTR szCmdLine,
            int iCmdShow)
    {
        int cxScreen, cyScreen;
        cxScreen = GetSystemMetrics(SM_CXSCREEN);
        cyScreen = GetSystemMetrics(SM_CYSCREEN);
        MsgBoxPrintf(L"ScreenSize",L"The Screen is %i Pixels Width and %i Pixels Height.***Resolution(%ix%i)***",
            cxScreen, cyScreen, cxScreen, cyScreen
        );


        return(0);

    }

除了字符输出都是一样的中文外,一切正常? symbol.No 无论我使用哪种 printf,我都无法得到正确的结果。 我做错了什么?

你对 _vsnwprintf_s 的倒数第二个论点是错误的。

_vsnwprintf_s(szBuffer, sizeof(szBuffer)/sizeof(wchar_t), 1024-1, szBuffer, pArgsList);
//                                                       this ======^

应该是szFormat;不是 szBuffer