用
CInternetSession session ;
m_pServer=session.GetHttpConnection(strServerName,nPort);
当http服务器没有开启,或者发送的URL错误、非法等,如何判断没有连接上http服务器?
CInternetSession session ;
m_pServer=session.GetHttpConnection(strServerName,nPort);
当http服务器没有开启,或者发送的URL错误、非法等,如何判断没有连接上http服务器?
解决方案 »
- MFC编贪吃蛇
- 有没有方法获得系统(windows)从bios接手那一刻到它启动起来所用的时间?
- 为一个对话框开一个线程
- CHtmlView里不能正常使用session
- 请教:ADO连接方式,读取Access2000表内字段值问题
- 如何用Static Text或者Picture控件在基于对话框的程序中进行OpenGL的图形绘制?
- 请问CEDIT如何限制输入的范围?
- 100分求教数据库问题!
- 那种http://www.some-site.com/script.exe?id=1234,那个exe文件是怎么回事了?
- MFC中文档标题设置
- 如何是使Cstatic控件响应鼠标右键事件!(超急,解决马上结贴)
- 外语对于程序员重要吗?大家进来谈谈感受
if (!m_pServer)
{
AfxMessageBox("连上服务器");
}
else
{
AfxMessageBox("没有连上服务器");
}
无论http服务器开启还是关闭,都提示"连上服务器".
CString strObject;
INTERNET_PORT nPort;
DWORD dwServiceType;
AfxMessageBox(sURL);
AfxMessageBox("HTTP_URL");
if (!AfxParseURL(sURL, dwServiceType, strServerName, strObject, nPort) ||
dwServiceType != INTERNET_SERVICE_HTTP)
{
AfxMessageBox("555");
}
AfxMessageBox("hhh");
就用我写的那些函数,怎么判断?
HINTERNET hConnect = NULL;
HINTERNET hURL = NULL;
BOOL bUseProxy;
CString strProxyName; m_hSession = ::InternetOpen("SiteSnagger",bUseProxy?INTERNET_OPEN_TYPE_PROXY:INTERNET_OPEN_TYPE_PRECONFIG, bUseProxy?(LPCTSTR)strProxyName:(LPCTSTR)NULL,NULL,0);
// Did it work??
if(m_hSession != NULL)
{
DWORD dwTimeout = 4000;
::InternetSetOption(m_hSession,INTERNET_OPTION_CONNECT_TIMEOUT,&dwTimeout,sizeof(dwTimeout));
}
else
return CInet::BAD_URL; hConnect = ::InternetConnect(m_hSession,strURL,
INTERNET_INVALID_PORT_NUMBER,
strUser,
strPassword,
INTERNET_SERVICE_HTTP,
0,
0) ;
hURL = ::HttpOpenRequest(hConnect,"GET",strObject,HTTP_VERSION,NULL,szTempX,dwHttpRequestFlags,0) ;
::HttpSendRequest(hURL,NULL,0,0,0);
if(hURL == NULL)
//调用失败 说明没有联上:(
hSession = InternetOpen("MyApp", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hSession)
{
HINTERNET hService;
hService = InternetOpenUrl(hSession, "http://www.microsoft.com/msj", NULL,
0, 0, 0);
if (hService)
{
...
}
}
InternetCloseHandle(hSession);