void ErrorMessage(LPCTSTR str, HRESULT hr)
{
void * pMsgBuf;
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER| FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) ,
(LPTSTR)&pMsgBuf,
0,
NULL
);
cout<<str<<"\r\n";
cout<<"Error("<<hex<<hr<<");"<<(LPTSTR)pMsgBuf<<endl;
LocalFree(pMsgBuf);
}