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

str*_*rax 0 c unicode winapi

VS2013社区edidtion操作系统: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);

    }
Run Code Online (Sandbox Code Playgroud)

一切都运行正常,除了字符输出是完全相同的中文?symbol.无论我使用哪种printf我都无法得到正确的结果.我做错了什么?

Who*_*aig 5

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

_vsnwprintf_s(szBuffer, sizeof(szBuffer)/sizeof(wchar_t), 1024-1, szBuffer, pArgsList);
//                                                       this ======^
Run Code Online (Sandbox Code Playgroud)

应该是szFormat; 不szBuffer