Internet函数“InternetOpenUrl”的用法

naile 2004-06-14 05:47:11
比如说要用“InternetOpenUrl”函数打开“http://192.0.1.100/abc/bb/a.txt",那么该函数的各个参数都应该是什么?(第一个参数“hInternetSession”就不用讲了)万分感谢
...全文
1128 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
roselu 2004-07-01
  • 打赏
  • 举报
回复
学习
gracezhu 2004-06-15
  • 打赏
  • 举报
回复
example code:
DWORD dwSize;
CHAR szHead[] = "Accept: */*\r\n\r\n";
VOID * szTemp[1024];
HINTERNET hConnect;
FILE * pFile;
HINTERNET hOpen = InternetOpen("Update1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( !(hConnect = InternetOpenUrl ( hOpen, m_sWebURL+"/update.zip", NULL,
0, 0, 0)))
{
return 0;
}
if ( !(pFile = fopen (m_CurrUpdatePath+"\\update.zip", "wb" ) ) )
{
return FALSE;
}
do
{
// Keep coping in 25 bytes chunks, while file has any data left.
// Note: bigger buffer will greatly improve performance.
if (!InternetReadFile (hConnect, szTemp, 1024, &dwSize) )
{
fclose (pFile);
return FALSE;
}
if (!dwSize)
break; // Condition of dwSize=0 indicate EOF. Stop.
else
fwrite(szTemp, sizeof (char), dwSize , pFile);
} // do
while (TRUE);
fflush (pFile);
fclose (pFile);
Wenxy1 2004-06-14
  • 打赏
  • 举报
回复
Syntax

HINTERNET InternetOpenUrl( HINTERNET hInternet,
LPCTSTR lpszUrl,
LPCTSTR lpszHeaders,
DWORD dwHeadersLength,
DWORD dwFlags,
DWORD_PTR dwContext
);
Parameters

hInternet
[in] HINTERNET handle to the current Internet session. The handle must have been returned by a previous call to InternetOpen.
lpszUrl
[in] Pointer to a string variable that contains the URL to begin reading. Only URLs beginning with ftp:, gopher:, http:, or https: are supported.
lpszHeaders
[in] Pointer to a string variable that contains the headers to be sent to the HTTP server. (For more information, see the description of the lpszHeaders parameter in the HttpSendRequest function.)
dwHeadersLength
[in] Unsigned long integer value that contains the length, in TCHARs, of the additional headers. If this parameter is -1L and lpszHeaders is not NULL, lpszHeaders is assumed to be zero-terminated (ASCIIZ) and the length is calculated.
dwFlags
[in] Unsigned long integer value that contains the API flags. This can be one of the following values:
INTERNET_FLAG_EXISTING_CONNECT
Attempts to use an existing InternetConnect object if one exists with the same attributes required to make the request. This is useful only with FTP operations, since FTP is the only protocol that typically performs multiple operations during the same session. The Microsoft® Win32® Internet API caches a single connection handle for each HINTERNET handle generated by InternetOpen.
INTERNET_FLAG_HYPERLINK
Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.
INTERNET_FLAG_IGNORE_CERT_CN_INVALID
Disables Win32 Internet function checking of SSL/PCT-based certificates that are returned from the server against the host name given in the request. Win32 Internet functions use a simple check against certificates by comparing for matching host names and simple wildcarding rules.
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
Disables Win32 Internet function checking of SSL/PCT-based certificates for proper validity dates.
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
Disables the ability of the Win32 Internet functions to detect this special type of redirect. When this flag is used, Win32 Internet functions transparently allow redirects from HTTPS to HTTP URLs.
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
Disables the ability of the Win32 Internet functions to detect this special type of redirect. When this flag is used, Win32 Internet functions transparently allow redirects from HTTP to HTTPS URLs.
INTERNET_FLAG_KEEP_CONNECTION
Uses keep-alive semantics, if available, for the connection. This flag is required for Microsoft Network (MSN), NT LAN Manager (NTLM), and other types of authentication.
INTERNET_FLAG_NEED_FILE
Causes a temporary file to be created if the file cannot be cached.
INTERNET_FLAG_NO_AUTH
Does not attempt authentication automatically.
INTERNET_FLAG_NO_AUTO_REDIRECT
Does not automatically handle redirection in HttpSendRequest.
INTERNET_FLAG_NO_CACHE_WRITE
Does not add the returned entity to the cache.
INTERNET_FLAG_NO_COOKIES
Does not automatically add cookie headers to requests, and does not automatically add returned cookies to the cookie database.
INTERNET_FLAG_NO_UI
Disables the cookie dialog box.
INTERNET_FLAG_PASSIVE
Uses passive FTP semantics. InternetOpenUrl uses this flag for FTP files and directories.
INTERNET_FLAG_PRAGMA_NOCACHE
Forces the request to be resolved by the origin server, even if a cached copy exists on the proxy.
INTERNET_FLAG_RAW_DATA
Returns the data as a GOPHER_FIND_DATA structure when retrieving Gopher directory information, or as a WIN32_FIND_DATA structure when retrieving FTP directory information. If this flag is not specified or if the call was made through a CERN proxy, InternetOpenUrl returns the HTML version of the directory.
INTERNET_FLAG_RELOAD
Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.
INTERNET_FLAG_RESYNCHRONIZE
Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded.
INTERNET_FLAG_SECURE
Uses secure transaction semantics. This translates to using Secure Sockets Layer/Private Communications Technology (SSL/PCT) and is only meaningful in HTTP requests.
dwContext
[in] Pointer to an unsigned long integer value that contains the application-defined value that is passed, along with the returned handle, to any callback functions.
Return Value

Returns a valid handle to the FTP, Gopher, or HTTP URL if the connection is successfully established, or NULL if the connection fails. To retrieve a specific error message, call GetLastError. To determine why access to the service was denied, call InternetGetLastResponseInfo.



蒋晟 2004-06-14
  • 打赏
  • 举报
回复
Q166961 HOWTO: FTP with CERN-Based Proxy Using WinInet API

18,363

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧