www.pudn.com > GGBT.rar > Common.cpp
// Common.cpp: implementation of the CCommon class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "testbt.h"
#include "Common.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
string ltostring(long lVal)
{
char str[100] = {0};
sprintf(str, "%d", (unsigned long) lVal);
return string(str);
}
string WSAShowError()
{
TCHAR errMsg[2048] = {0};
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
GetModuleHandle(TEXT("ws2_32.dll")), WSAGetLastError(),
NULL,
errMsg,
sizeof(errMsg)/sizeof(TCHAR),
NULL);
// MessageBox(ghMainWnd, errMsg, TEXT("ws2_32.dll"), MB_ICONERROR);
return string(errMsg);
}
bool IsEventSet(HANDLE hEvent)
{
return WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0;
}