#include <stdlib.h>
#include <stdio.h>
...
STDMETHODIMP CSimpleCOMObject2::TestMethod1()
{
// TODO: Add your implementation code here
TCHAR szMessage[256]; sprintf (szMessage, "Thread ID : 0x%X", GetCurrentThreadId()); ::MessageBox(NULL, szMessage, "TestMethod1()", MB_OK); return S_OK;
}
编译结果:(没有加stdlib.h和stdio.h之前)
error C2065: 'sprintf' : undeclared identifier
error C2664: 'MessageBoxW' : cannot convert parameter 3 from 'char [14]' to 'const unsigned short *'
编译结果:(没有加stdlib.h和stdio.h之后)
error C2664: 'sprintf' : cannot convert parameter 1 from 'unsigned short [256]' to 'char *'
rror C2664: 'MessageBoxW' : cannot convert parameter 3 from 'char [14]' to 'const unsigned short *'