0
我正在使用WSAGetLastError函數檢索使用getHostByName函數時的失敗詳細信息。但該函數返回的錯誤代碼0042124C在文檔中不可用。我是否以其他格式接收錯誤代碼,或者我是否以錯誤的方式使用該功能?WSAGetLastError錯誤代碼未知
謝謝。
PS。下面
// DNS Hostname.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "DNS Hostname.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(2, 2);
err = WSAStartup(wVersionRequested, &wsaData);
HOSTENT* pHostDetails = NULL;
pHostDetails = gethostbyname("IE10-FLYFB1S");
if(pHostDetails)
{
int nList = 0;
CString sAddressString;
CString sSQLAddress;
CString sSQLMachine;
unsigned long addr;
while (pHostDetails->h_addr_list[nList])
{
addr = (*(u_long FAR *) pHostDetails->h_addr_list[nList]);
sAddressString.Format(_T("%d.%d.%d.%d"),(addr & 255),((addr >> 8) & 255),((addr >> 16) & 255),((addr >> 24) & 255));
sSQLAddress.Format(_T(" OR Machine = '%s' "),sAddressString);
sSQLMachine += sSQLAddress;
nList++;
}
cout << sSQLMachine << endl;
}
else
{
int error = WSAGetLastError();
cout << error << endl;
}
}
WSACleanup();
return nRetCode;
}
不以任何方式解釋現象。 – EJP 2017-10-04 18:42:08