common.cpp
资源名称:Direct90.rar [点击查看]
上传用户:maxzhb99
上传日期:2013-03-13
资源大小:48k
文件大小:1k
源码类别:
DirextX编程
开发平台:
Visual C++
- #include "stdafx.h"
- #include "common.h"
- void Msg(TCHAR *szFormat, ...)
- {
- TCHAR szBuffer[1024]; // Large buffer for long filenames or URLs
- const size_t NUMCHARS = sizeof(szBuffer) / sizeof(szBuffer[0]);
- const int LASTCHAR = NUMCHARS - 1;
- // Format the input string
- va_list pArgs;
- va_start(pArgs, szFormat);
- // Use a bounded buffer size to prevent buffer overruns. Limit count to
- // character size minus one to allow for a NULL terminating character.
- _vsntprintf(szBuffer, NUMCHARS - 1, szFormat, pArgs);
- va_end(pArgs);
- // Ensure that the formatted string is NULL-terminated
- szBuffer[LASTCHAR] = TEXT(' ');
- // Display a message box with the formatted string
- MessageBox(NULL, szBuffer, TEXT("VMR Text Sample"), MB_OK);
- }