Win32
view release on metacpan or search on metacpan
Revision history for the Perl extension Win32.
0.59 [2022-05-05]
- add Win32::GetChipArch and use it in Win32::GetOSName to support arm/arm64
architecture by Pierrick Bouvier [PR/34]
0.58 [2022-01-17]
- add Win32::HttpGetFile (thanks to Craig Berry for the implementation
and Tomasz Konojacki for code review) [PR/30]
- skip failing Unicode.t on Cygwin because cwd() no longer returns an
ANSI (short) path there.
- Fixed test 14,15 of GetFullPathName.t when package is unpacked in a
top level folder (thanks to Jianhong Feng) [PR/20]
0.57 [2021-03-10]
- fix calling convention for PFNRegGetValueA [PR/28]
0.56 [2021-03-07]
persistent identifier in a distributed setting. To a very high degree
of certainty this function returns a unique value. No other
invocation, on the same or any other system (networked or not), should
return the same value.
The return value is formatted according to OLE conventions, as groups
of hex digits with surrounding braces. For example:
{09531CF1-D0C7-4860-840C-1C8C8735E2AD}
=item Win32::HttpGetFile(URL, FILENAME [, IGNORE_CERT_ERRORS])
Uses the WinHttp library to download the file specified by the URL
parameter to the local file specified by FILENAME. The optional third
parameter, if true, indicates that certficate errors are to be ignored
for https connections; please use with caution in a safe environment,
such as when testing locally using a self-signed certificate.
Only http and https protocols are supported. Authentication is not
supported. The function is not available when building with gcc prior to
4.8.0 because the WinHttp library is not available.
context also returns, in addition to the boolean status, a second
value containing message text related to the status.
If the call fails, C<Win32::GetLastError()> will return a numeric
error code, which may be a system error, a WinHttp error, or a
user-defined error composed of 1e9 plus the HTTP status code.
Scalar context example:
print Win32::GetLastError()
unless Win32::HttpGetFile('http://example.com/somefile.tar.gz',
'.\file.tgz');
List context example:
my ($ok, $msg) = Win32::HttpGetFile('http://example.com/somefile.tar.gz',
'.\file.tgz');
if ($ok) {
print "Success!: $msg\n";
}
else {
print "Failure!: $msg\n";
my $err = Win32::GetLastError();
if ($err > 1e9) {
printf "HTTP status: %d\n", ($err - 1e9);
}
);
if (status == ERROR_SUCCESS && val == 1)
XSRETURN_YES;
XSRETURN_NO;
}
#ifdef WINHTTPAPI
XS(w32_HttpGetFile)
{
dXSARGS;
WCHAR *url = NULL, *file = NULL, *hostName = NULL, *urlPath = NULL;
bool bIgnoreCertErrors = FALSE;
WCHAR msgbuf[ONE_K_BUFSIZE];
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;
HANDLE hOut = INVALID_HANDLE_VALUE;
BOOL bParsed = FALSE,
bAborted = FALSE,
bFileError = FALSE,
bHttpError = FALSE;
DWORD error = 0;
URL_COMPONENTS urlComp;
LPCWSTR acceptTypes[] = { L"*/*", NULL };
DWORD dwHttpStatusCode = 0, dwQuerySize = 0;
if (items < 2 || items > 3)
croak("usage: Win32::HttpGetFile($url, $file[, $ignore_cert_errors])");
url = sv_to_wstr(aTHX_ ST(0));
file = sv_to_wstr(aTHX_ ST(1));
if (items == 3)
bIgnoreCertErrors = (BOOL)SvIV(ST(2));
/* Initialize the URL_COMPONENTS structure, setting the required
* component lengths to non-zero so that they get populated.
*/
if(WinHttpGetProxyForUrl(hSession,
url,
&AutoProxyOptions,
&ProxyInfo)) {
if(!WinHttpSetOption(hRequest,
WINHTTP_OPTION_PROXY,
&ProxyInfo,
cbProxyInfoSize)) {
bAborted = TRUE;
Perl_warn(aTHX_ "Win32::HttpGetFile: setting proxy options failed");
}
Safefree(ProxyInfo.lpszProxy);
Safefree(ProxyInfo.lpszProxyBypass);
}
}
/* Send a request. */
if (hRequest && !bAborted)
bResults = WinHttpSendRequest(hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
newXS("Win32::GetConsoleOutputCP", w32_GetConsoleOutputCP, file);
newXS("Win32::GetOEMCP", w32_GetOEMCP, file);
newXS("Win32::SetConsoleCP", w32_SetConsoleCP, file);
newXS("Win32::SetConsoleOutputCP", w32_SetConsoleOutputCP, file);
newXS("Win32::GetProcessPrivileges", w32_GetProcessPrivileges, file);
newXS("Win32::IsDeveloperModeEnabled", w32_IsDeveloperModeEnabled, file);
#ifdef __CYGWIN__
newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file);
#endif
#ifdef WINHTTPAPI
newXS("Win32::HttpGetFile", w32_HttpGetFile, file);
#endif
XSRETURN_YES;
}
( run in 0.892 second using v1.01-cache-2.11-cpan-a5abf4f5562 )