4281
- 收藏
- 点赞
- 分享
- 举报
windows mobile下GPRS自动拨号
#define GOOGLEWEBPAGE _T("/DevDivFile.xml")
#define STLOG_WRITE(a) MessageBox(NULL,a,NULL,0)
void DestroyConnection( HANDLE hConnect )
{
// If a connection exists, destroy it
if(NULL != hConnect )
{
ConnMgrReleaseConnection(hConnect, FALSE);
}
}
int CreateConnection( HANDLE *phConnection )
{
HRESULT hResult;
// HANDLE phConnection;
DWORD dwStatus;
DWORD dwResult;
CONNMGR_DESTINATION_INFO cdi;
int i;
for(i = 0; SUCCEEDED(ConnMgrEnumDestinations(i, &cdi)); i++)
{
if (0 == wcscmp(cdi.szDescription, _T("WAP")))
break;
}
hResult = ConnMgrEnumDestinations(i, &cdi);
if (FAILED(hResult))
return FALSE;
CONNMGR_CONNECTIONINFO ConnInfo;
ZeroMemory( &ConnInfo, sizeof( ConnInfo ) );
ConnInfo.cbSize = sizeof( ConnInfo );
ConnInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
ConnInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
ConnInfo.dwFlags = CONNMGR_FLAG_PROXY_HTTP | CONNMGR_FLAG_PROXY_WAP | CONNMGR_FLAG_PROXY_SOCKS4 | CONNMGR_FLAG_PROXY_SOCKS5;
ConnInfo.bExclusive = FALSE;
ConnInfo.bDisabled = FALSE;
ConnInfo.guidDestNet = cdi.guid;
STLOG_WRITE(_T("ConnectToHttpServer\n") );
hResult = ConnMgrEstablishConnectionSync( &ConnInfo, phConnection, 60000, &dwStatus );
if ( hResult != S_OK )
{
STLOG_WRITE(_T("ConnMgrEstablishConnection is error\n") );
dwResult = GetLastError();
return S_FALSE;
}
else
{
// do something
}
return S_OK;
}
BOOL ConnectToHttpGetServer( LPCTSTR lpszServerName, LPCTSTR lpszObjectName )
{
BOOL bResult;
DWORD dwResult;
HANDLE hConnection;
DWORD dwWritten;
LPTSTR szReadBuffer;
DWORD dwNumberOfBytesRead;
int nContentLength;
DWORD dwTotalRead;
hConnection = NULL;
bResult = FALSE;
nContentLength = 0;
dwNumberOfBytesRead = 0;
dwTotalRead = 0;
dwWritten = 0;
if( CreateConnection( &hConnection ) != S_OK )
return FALSE;
HINTERNET hInternet = InternetOpen( _T("DevDiv"), INTERNET_OPEN_TYPE_PROXY, _T("10.0.0.172"), NULL, 0);
if ( hInternet == NULL )
{
STLOG_WRITE(_T("InternetOpen is error\n") );
dwResult = GetLastError();
return bResult;
}
HINTERNET hInternetConnect = InternetConnect( hInternet, lpszServerName, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1 );
if ( hInternetConnect == NULL )
{
STLOG_WRITE(_T("InternetConnect is error\n") );
dwResult = GetLastError();
return bResult;
}
//TCHAR szAccept[] = L"*/*"; //we accept everything...
//LPTSTR AcceptTypes[2]={0};
//AcceptTypes[0]=szAccept;
HINTERNET hRequest = HttpOpenRequest(hInternetConnect,_T("GET"),lpszObjectName, L"HTTP/1.1",NULL,(LPCTSTR *)NULL,0,1);
if (!hRequest)
{
dwResult = GetLastError();
STLOG_WRITE(_T("HttpOpenRequest is error\n") );
return bResult;
}
BOOL bSuccess = HttpSendRequest(hRequest, NULL, 0, NULL, 0 );
if ( !bSuccess )
{
STLOG_WRITE(_T("HttpSendRequestEx is error\n") );
dwResult = GetLastError();
return bResult;
}
TCHAR szHeader[ 1000 ];
ZeroMemory( szHeader, sizeof( szHeader ) );
DWORD dwHeaderLength = sizeof( szHeader );
// HTTP_QUERY_RAW_HEADERS
BOOL bQuery=HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH, szHeader, &dwHeaderLength, NULL);
if ( !bQuery )
{
STLOG_WRITE(_T("HttpQueryInfo is error\n") );
dwResult = GetLastError();
return bResult;
}
nContentLength = _wtoi( szHeader );
HANDLE hFile = CreateFile( GOOGLEWEBPAGE, GENERIC_READ|GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if ( hFile == INVALID_HANDLE_VALUE )
{
dwResult = GetLastError();
return bResult;
}
szReadBuffer = (LPTSTR) malloc( 1024 );
ZeroMemory(szReadBuffer, 1024 );
while( TRUE )
{
bResult = InternetReadFile(hRequest, szReadBuffer, 1024, &dwNumberOfBytesRead);
if ( bResult )
{
if ( dwTotalRead == nContentLength && dwNumberOfBytesRead == 0 )
{
bResult = TRUE;
break;
}
else
{
SetFilePointer ( hFile, 0, NULL, FILE_END );
WriteFile( hFile,(LPBYTE)szReadBuffer, dwNumberOfBytesRead, &dwWritten, NULL );
dwTotalRead = dwTotalRead + dwNumberOfBytesRead;
}
}
else
{
bResult = FALSE;
break;
}
}
CloseHandle(hFile);
free(szReadBuffer);
InternetCloseHandle( hInternetConnect );
InternetCloseHandle( hInternet );
DestroyConnection( hConnection );
STLOG_WRITE(_T("\n") );
return bResult;
}
fromwww.devdiv.net
#define STLOG_WRITE(a) MessageBox(NULL,a,NULL,0)
void DestroyConnection( HANDLE hConnect )
{
// If a connection exists, destroy it
if(NULL != hConnect )
{
ConnMgrReleaseConnection(hConnect, FALSE);
}
}
int CreateConnection( HANDLE *phConnection )
{
HRESULT hResult;
// HANDLE phConnection;
DWORD dwStatus;
DWORD dwResult;
CONNMGR_DESTINATION_INFO cdi;
int i;
for(i = 0; SUCCEEDED(ConnMgrEnumDestinations(i, &cdi)); i++)
{
if (0 == wcscmp(cdi.szDescription, _T("WAP")))
break;
}
hResult = ConnMgrEnumDestinations(i, &cdi);
if (FAILED(hResult))
return FALSE;
CONNMGR_CONNECTIONINFO ConnInfo;
ZeroMemory( &ConnInfo, sizeof( ConnInfo ) );
ConnInfo.cbSize = sizeof( ConnInfo );
ConnInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
ConnInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
ConnInfo.dwFlags = CONNMGR_FLAG_PROXY_HTTP | CONNMGR_FLAG_PROXY_WAP | CONNMGR_FLAG_PROXY_SOCKS4 | CONNMGR_FLAG_PROXY_SOCKS5;
ConnInfo.bExclusive = FALSE;
ConnInfo.bDisabled = FALSE;
ConnInfo.guidDestNet = cdi.guid;
STLOG_WRITE(_T("ConnectToHttpServer\n") );
hResult = ConnMgrEstablishConnectionSync( &ConnInfo, phConnection, 60000, &dwStatus );
if ( hResult != S_OK )
{
STLOG_WRITE(_T("ConnMgrEstablishConnection is error\n") );
dwResult = GetLastError();
return S_FALSE;
}
else
{
// do something
}
return S_OK;
}
BOOL ConnectToHttpGetServer( LPCTSTR lpszServerName, LPCTSTR lpszObjectName )
{
BOOL bResult;
DWORD dwResult;
HANDLE hConnection;
DWORD dwWritten;
LPTSTR szReadBuffer;
DWORD dwNumberOfBytesRead;
int nContentLength;
DWORD dwTotalRead;
hConnection = NULL;
bResult = FALSE;
nContentLength = 0;
dwNumberOfBytesRead = 0;
dwTotalRead = 0;
dwWritten = 0;
if( CreateConnection( &hConnection ) != S_OK )
return FALSE;
HINTERNET hInternet = InternetOpen( _T("DevDiv"), INTERNET_OPEN_TYPE_PROXY, _T("10.0.0.172"), NULL, 0);
if ( hInternet == NULL )
{
STLOG_WRITE(_T("InternetOpen is error\n") );
dwResult = GetLastError();
return bResult;
}
HINTERNET hInternetConnect = InternetConnect( hInternet, lpszServerName, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1 );
if ( hInternetConnect == NULL )
{
STLOG_WRITE(_T("InternetConnect is error\n") );
dwResult = GetLastError();
return bResult;
}
//TCHAR szAccept[] = L"*/*"; //we accept everything...
//LPTSTR AcceptTypes[2]={0};
//AcceptTypes[0]=szAccept;
HINTERNET hRequest = HttpOpenRequest(hInternetConnect,_T("GET"),lpszObjectName, L"HTTP/1.1",NULL,(LPCTSTR *)NULL,0,1);
if (!hRequest)
{
dwResult = GetLastError();
STLOG_WRITE(_T("HttpOpenRequest is error\n") );
return bResult;
}
BOOL bSuccess = HttpSendRequest(hRequest, NULL, 0, NULL, 0 );
if ( !bSuccess )
{
STLOG_WRITE(_T("HttpSendRequestEx is error\n") );
dwResult = GetLastError();
return bResult;
}
TCHAR szHeader[ 1000 ];
ZeroMemory( szHeader, sizeof( szHeader ) );
DWORD dwHeaderLength = sizeof( szHeader );
// HTTP_QUERY_RAW_HEADERS
BOOL bQuery=HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH, szHeader, &dwHeaderLength, NULL);
if ( !bQuery )
{
STLOG_WRITE(_T("HttpQueryInfo is error\n") );
dwResult = GetLastError();
return bResult;
}
nContentLength = _wtoi( szHeader );
HANDLE hFile = CreateFile( GOOGLEWEBPAGE, GENERIC_READ|GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if ( hFile == INVALID_HANDLE_VALUE )
{
dwResult = GetLastError();
return bResult;
}
szReadBuffer = (LPTSTR) malloc( 1024 );
ZeroMemory(szReadBuffer, 1024 );
while( TRUE )
{
bResult = InternetReadFile(hRequest, szReadBuffer, 1024, &dwNumberOfBytesRead);
if ( bResult )
{
if ( dwTotalRead == nContentLength && dwNumberOfBytesRead == 0 )
{
bResult = TRUE;
break;
}
else
{
SetFilePointer ( hFile, 0, NULL, FILE_END );
WriteFile( hFile,(LPBYTE)szReadBuffer, dwNumberOfBytesRead, &dwWritten, NULL );
dwTotalRead = dwTotalRead + dwNumberOfBytesRead;
}
}
else
{
bResult = FALSE;
break;
}
}
CloseHandle(hFile);
free(szReadBuffer);
InternetCloseHandle( hInternetConnect );
InternetCloseHandle( hInternet );
DestroyConnection( hConnection );
STLOG_WRITE(_T("\n") );
return bResult;
}
fromwww.devdiv.net
我来回答
回答0个
时间排序
认可量排序
暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2012-12-04 13:53:05
-
2012-12-04 11:55:04
-
2008-08-27 23:28:34
-
2008-08-27 23:29:54
-
2012-12-04 11:37:28
-
2008-08-14 01:01:56
-
2012-12-04 13:07:48
-
2012-12-04 13:04:58
-
2012-12-05 11:07:55
-
2012-12-04 14:09:01
-
2012-12-04 11:57:50
-
2012-12-04 12:57:16
-
2012-12-04 11:51:25
-
2008-07-06 21:15:38
-
2012-12-04 11:57:10
-
2008-05-26 22:18:30
-
2012-12-04 13:08:38
-
2012-12-04 11:49:35
-
2012-12-04 11:46:15
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认