0

i want to show the messsagebox using win32 API...

int pwdexpirydays=5; MessageBox(hdlg,(LPCSTR)("Your password will expire in %d days",&pwdexpirydays),(LPCSTR)"Logon Message",MB_OK | MB_ICONINFORMATION);

But i cant get the value...

How to i concate the pwdexpirydays values into "Your password will expire in %d days" this string.

4

2 回答 2

3

如果您经常这样做,您可能需要考虑一个使其快速简便的功能。

int MsgBoxPrint(HWND hWnd, int Type, char *Caption, char *Format, ...)
{
    va_list ArgList;
    char Temp[4096];

    va_start(ArgList, Format);
    vsnprintf(Temp, 4096, Format, ArgList); 
    va_end(ArgList);

    return MessageBox(hWnd, Temp, Caption, Type);
}

然后你会这样称呼它:

MsgBoxPrint(hdlg, MB_OK | MB_ICONINFORMATION, "Logon Message", \
     "Your password will expire in %d days", pwdexpirydays);
于 2012-10-31T05:59:45.700 回答
3

您可以使用snprintf或 std::string 进行连接。

于 2012-10-31T05:52:33.703 回答