| |
| INT WINAPI WebViewEnumDownloads( |
| |
HWND hWndHost, |
|
| |
DWORD dwStatus, |
|
| |
LPDWORD lpdwFileList, |
|
| |
INT nMaxFiles |
|
| ); |
The WebViewEnumDownloads function enumerates the file identifiers for
downloads during the current session.
Parameters
- hWndHost
- Handle to the window attached to the browser session.
- dwStatus
- A value which specifies the status of the downloads to enumerate.
If this value is zero, the function will enumerate all downloads.
If this parameter is one of the values listed below, only those downloads
which match the specified status will be enumerated. For example, if
this parameter is
WEBVIEW_DOWNLOAD_COMPLETED then only
those file downloads which have completed will be enumerated.
| Name |
Description |
| WEBVIEW_DOWNLOAD_STARTED |
The file download has started and is in-progress. |
| WEBVIEW_DOWNLOAD_COMPLETED |
The file download has completed successfully. |
| WEBVIEW_DOWNLOAD_CANCELED |
The file download has been canceled. |
| WEBVIEW_DOWNLOAD_FAILED |
The file download failed due to a network error or other problem. |
- lpdwFileList
- A pointer to an array of DWORD values which specify the unique
file identifier associated with the download. The identifiers can be
passed to the WebViewGetDownloadInfo function to get detailed
information about a specific download. This parameter can be NULL,
in which case it will be ignored and the function will return the
number of downloaded files.
- nMaxFiles
- The maximum number of file identifiers which can be copied into
the lpdwFileList array. If the lpdwFileList parameter
is NULL this value should be zero.
Return Value
If the function succeeds, the return value is the number of files
downloaded during the current session. If there have been no downloads,
or if the function fails, the return value is zero. To get extended
error information, call WebViewGetLastError.
Remarks
The WebViewEnumDownloads function can be used to obtain the
identifiers for one or more file downloads that have occurred during
the current browser session. Each identifier returned by this function
uniquely corresponds to a download and can be used with functions such
as WebViewGetDownloadInfo or WebViewGetDownloadPath to
obtain detailed information about the file.
If the dwStatus parameter is set to zero, the function
enumerates all downloads regardless of their state. Otherwise, only
downloads that match the specified status value are included in the
enumeration. This allows applications to filter the results to include
only downloads that are currently in progress, those that completed
successfully, or those that were canceled or failed.
When the lpdwFileList parameter is not NULL, the function
copies up to nMaxFiles identifiers into the specified array. If
the number of matching downloads exceeds the array size, only the
first nMaxFiles identifiers are returned, but the return value
will still reflect the total number of matching downloads. This
enables the application to first call the function with a NULL pointer
to determine how many downloads are available, and then allocate an
appropriately sized buffer before retrieving the identifiers.
The enumeration includes both active and completed downloads. If
the host window is detached or destroyed, the list of downloads is
cleared and further enumeration will return zero results.
Example
INT nTotal = WebViewEnumDownloads(hWndHost, 0, NULL, 0);
if (nTotal <= 0)
{
_tprintf(_T("No downloads found.\n"));
return;
}
DWORD *pIds = (DWORD*)malloc(nTotal * sizeof(DWORD));
if (!pIds)
return;
INT nCount = WebViewEnumDownloads(hWndHost, 0, pIds, nTotal);
for (INT nIndex = 0; nIndex < nCount; nIndex++)
{
WEBVIEW_DOWNLOAD_INFO fileInfo = { sizeof(fileInfo) };
if (WebViewGetDownloadInfo(hWndHost, pIds[nIndex], &fileInfo))
{
_tprintf(_T("Download %u: %s (%llu/%llu bytes)\n"),
fileInfo.dwFileId,
fileInfo.szFileName,
fileInfo.uiBytesCopied.QuadPart,
fileInfo.uiBytesTotal.QuadPart);
}
}
free(pIds);
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib
See Also
|
|