ホーム › Networking.WinInet › GetUrlCacheEntryInfoExA
GetUrlCacheEntryInfoExA
関数リダイレクト対応でURLキャッシュエントリ情報を取得する(ANSI版)。
シグネチャ
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL GetUrlCacheEntryInfoExA(
LPCSTR lpszUrl,
INTERNET_CACHE_ENTRY_INFOA* lpCacheEntryInfo, // optional
DWORD* lpcbCacheEntryInfo, // optional
LPSTR lpszRedirectUrl, // optional
DWORD* lpcbRedirectUrl, // optional
void* lpReserved, // optional
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpszUrl | LPCSTR | in | 情報を取得するキャッシュエントリのURLを指すANSI文字列。 |
| lpCacheEntryInfo | INTERNET_CACHE_ENTRY_INFOA* | inoutoptional | キャッシュエントリ情報を受け取るINTERNET_CACHE_ENTRY_INFOA構造体へのポインター。NULL可。 |
| lpcbCacheEntryInfo | DWORD* | inoutoptional | lpCacheEntryInfoバッファのサイズ(バイト)を入出力するポインター。 |
| lpszRedirectUrl | LPSTR | optional | リダイレクト先URLを受け取るANSIバッファ。不要ならNULL。 |
| lpcbRedirectUrl | DWORD* | optional | lpszRedirectUrlバッファのサイズを入出力するポインター。 |
| lpReserved | void* | optional | 将来の拡張用の予約引数。NULLを指定する。 |
| dwFlags | DWORD | in | 取得動作を制御するフラグ。リダイレクト追跡の有無等を指定する。 |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL GetUrlCacheEntryInfoExA(
LPCSTR lpszUrl,
INTERNET_CACHE_ENTRY_INFOA* lpCacheEntryInfo, // optional
DWORD* lpcbCacheEntryInfo, // optional
LPSTR lpszRedirectUrl, // optional
DWORD* lpcbRedirectUrl, // optional
void* lpReserved, // optional
DWORD dwFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool GetUrlCacheEntryInfoExA(
[MarshalAs(UnmanagedType.LPStr)] string lpszUrl, // LPCSTR
IntPtr lpCacheEntryInfo, // INTERNET_CACHE_ENTRY_INFOA* optional, in/out
IntPtr lpcbCacheEntryInfo, // DWORD* optional, in/out
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszRedirectUrl, // LPSTR optional
IntPtr lpcbRedirectUrl, // DWORD* optional
IntPtr lpReserved, // void* optional
uint dwFlags // DWORD
);<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetUrlCacheEntryInfoExA(
<MarshalAs(UnmanagedType.LPStr)> lpszUrl As String, ' LPCSTR
lpCacheEntryInfo As IntPtr, ' INTERNET_CACHE_ENTRY_INFOA* optional, in/out
lpcbCacheEntryInfo As IntPtr, ' DWORD* optional, in/out
<MarshalAs(UnmanagedType.LPStr)> lpszRedirectUrl As System.Text.StringBuilder, ' LPSTR optional
lpcbRedirectUrl As IntPtr, ' DWORD* optional
lpReserved As IntPtr, ' void* optional
dwFlags As UInteger ' DWORD
) As Boolean
End Function' lpszUrl : LPCSTR
' lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out
' lpcbCacheEntryInfo : DWORD* optional, in/out
' lpszRedirectUrl : LPSTR optional
' lpcbRedirectUrl : DWORD* optional
' lpReserved : void* optional
' dwFlags : DWORD
Declare PtrSafe Function GetUrlCacheEntryInfoExA Lib "wininet" ( _
ByVal lpszUrl As String, _
ByVal lpCacheEntryInfo As LongPtr, _
ByVal lpcbCacheEntryInfo As LongPtr, _
ByVal lpszRedirectUrl As String, _
ByVal lpcbRedirectUrl As LongPtr, _
ByVal lpReserved As LongPtr, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetUrlCacheEntryInfoExA = ctypes.windll.wininet.GetUrlCacheEntryInfoExA
GetUrlCacheEntryInfoExA.restype = wintypes.BOOL
GetUrlCacheEntryInfoExA.argtypes = [
wintypes.LPCSTR, # lpszUrl : LPCSTR
ctypes.c_void_p, # lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out
ctypes.POINTER(wintypes.DWORD), # lpcbCacheEntryInfo : DWORD* optional, in/out
wintypes.LPSTR, # lpszRedirectUrl : LPSTR optional
ctypes.POINTER(wintypes.DWORD), # lpcbRedirectUrl : DWORD* optional
ctypes.POINTER(None), # lpReserved : void* optional
wintypes.DWORD, # dwFlags : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
GetUrlCacheEntryInfoExA = Fiddle::Function.new(
lib['GetUrlCacheEntryInfoExA'],
[
Fiddle::TYPE_VOIDP, # lpszUrl : LPCSTR
Fiddle::TYPE_VOIDP, # lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out
Fiddle::TYPE_VOIDP, # lpcbCacheEntryInfo : DWORD* optional, in/out
Fiddle::TYPE_VOIDP, # lpszRedirectUrl : LPSTR optional
Fiddle::TYPE_VOIDP, # lpcbRedirectUrl : DWORD* optional
Fiddle::TYPE_VOIDP, # lpReserved : void* optional
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn GetUrlCacheEntryInfoExA(
lpszUrl: *const u8, // LPCSTR
lpCacheEntryInfo: *mut INTERNET_CACHE_ENTRY_INFOA, // INTERNET_CACHE_ENTRY_INFOA* optional, in/out
lpcbCacheEntryInfo: *mut u32, // DWORD* optional, in/out
lpszRedirectUrl: *mut u8, // LPSTR optional
lpcbRedirectUrl: *mut u32, // DWORD* optional
lpReserved: *mut (), // void* optional
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool GetUrlCacheEntryInfoExA([MarshalAs(UnmanagedType.LPStr)] string lpszUrl, IntPtr lpCacheEntryInfo, IntPtr lpcbCacheEntryInfo, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszRedirectUrl, IntPtr lpcbRedirectUrl, IntPtr lpReserved, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_GetUrlCacheEntryInfoExA' -Namespace Win32 -PassThru
# $api::GetUrlCacheEntryInfoExA(lpszUrl, lpCacheEntryInfo, lpcbCacheEntryInfo, lpszRedirectUrl, lpcbRedirectUrl, lpReserved, dwFlags)#uselib "WININET.dll"
#func global GetUrlCacheEntryInfoExA "GetUrlCacheEntryInfoExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GetUrlCacheEntryInfoExA lpszUrl, varptr(lpCacheEntryInfo), varptr(lpcbCacheEntryInfo), varptr(lpszRedirectUrl), varptr(lpcbRedirectUrl), lpReserved, dwFlags ; 戻り値は stat
; lpszUrl : LPCSTR -> "sptr"
; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "sptr"
; lpcbCacheEntryInfo : DWORD* optional, in/out -> "sptr"
; lpszRedirectUrl : LPSTR optional -> "sptr"
; lpcbRedirectUrl : DWORD* optional -> "sptr"
; lpReserved : void* optional -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global GetUrlCacheEntryInfoExA "GetUrlCacheEntryInfoExA" str, var, var, var, var, sptr, int ; res = GetUrlCacheEntryInfoExA(lpszUrl, lpCacheEntryInfo, lpcbCacheEntryInfo, lpszRedirectUrl, lpcbRedirectUrl, lpReserved, dwFlags) ; lpszUrl : LPCSTR -> "str" ; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "var" ; lpcbCacheEntryInfo : DWORD* optional, in/out -> "var" ; lpszRedirectUrl : LPSTR optional -> "var" ; lpcbRedirectUrl : DWORD* optional -> "var" ; lpReserved : void* optional -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global GetUrlCacheEntryInfoExA "GetUrlCacheEntryInfoExA" str, sptr, sptr, sptr, sptr, sptr, int ; res = GetUrlCacheEntryInfoExA(lpszUrl, varptr(lpCacheEntryInfo), varptr(lpcbCacheEntryInfo), varptr(lpszRedirectUrl), varptr(lpcbRedirectUrl), lpReserved, dwFlags) ; lpszUrl : LPCSTR -> "str" ; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "sptr" ; lpcbCacheEntryInfo : DWORD* optional, in/out -> "sptr" ; lpszRedirectUrl : LPSTR optional -> "sptr" ; lpcbRedirectUrl : DWORD* optional -> "sptr" ; lpReserved : void* optional -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetUrlCacheEntryInfoExA(LPCSTR lpszUrl, INTERNET_CACHE_ENTRY_INFOA* lpCacheEntryInfo, DWORD* lpcbCacheEntryInfo, LPSTR lpszRedirectUrl, DWORD* lpcbRedirectUrl, void* lpReserved, DWORD dwFlags) #uselib "WININET.dll" #cfunc global GetUrlCacheEntryInfoExA "GetUrlCacheEntryInfoExA" str, var, var, var, var, intptr, int ; res = GetUrlCacheEntryInfoExA(lpszUrl, lpCacheEntryInfo, lpcbCacheEntryInfo, lpszRedirectUrl, lpcbRedirectUrl, lpReserved, dwFlags) ; lpszUrl : LPCSTR -> "str" ; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "var" ; lpcbCacheEntryInfo : DWORD* optional, in/out -> "var" ; lpszRedirectUrl : LPSTR optional -> "var" ; lpcbRedirectUrl : DWORD* optional -> "var" ; lpReserved : void* optional -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetUrlCacheEntryInfoExA(LPCSTR lpszUrl, INTERNET_CACHE_ENTRY_INFOA* lpCacheEntryInfo, DWORD* lpcbCacheEntryInfo, LPSTR lpszRedirectUrl, DWORD* lpcbRedirectUrl, void* lpReserved, DWORD dwFlags) #uselib "WININET.dll" #cfunc global GetUrlCacheEntryInfoExA "GetUrlCacheEntryInfoExA" str, intptr, intptr, intptr, intptr, intptr, int ; res = GetUrlCacheEntryInfoExA(lpszUrl, varptr(lpCacheEntryInfo), varptr(lpcbCacheEntryInfo), varptr(lpszRedirectUrl), varptr(lpcbRedirectUrl), lpReserved, dwFlags) ; lpszUrl : LPCSTR -> "str" ; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "intptr" ; lpcbCacheEntryInfo : DWORD* optional, in/out -> "intptr" ; lpszRedirectUrl : LPSTR optional -> "intptr" ; lpcbRedirectUrl : DWORD* optional -> "intptr" ; lpReserved : void* optional -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procGetUrlCacheEntryInfoExA = wininet.NewProc("GetUrlCacheEntryInfoExA")
)
// lpszUrl (LPCSTR), lpCacheEntryInfo (INTERNET_CACHE_ENTRY_INFOA* optional, in/out), lpcbCacheEntryInfo (DWORD* optional, in/out), lpszRedirectUrl (LPSTR optional), lpcbRedirectUrl (DWORD* optional), lpReserved (void* optional), dwFlags (DWORD)
r1, _, err := procGetUrlCacheEntryInfoExA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszUrl))),
uintptr(lpCacheEntryInfo),
uintptr(lpcbCacheEntryInfo),
uintptr(lpszRedirectUrl),
uintptr(lpcbRedirectUrl),
uintptr(lpReserved),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetUrlCacheEntryInfoExA(
lpszUrl: PAnsiChar; // LPCSTR
lpCacheEntryInfo: Pointer; // INTERNET_CACHE_ENTRY_INFOA* optional, in/out
lpcbCacheEntryInfo: Pointer; // DWORD* optional, in/out
lpszRedirectUrl: PAnsiChar; // LPSTR optional
lpcbRedirectUrl: Pointer; // DWORD* optional
lpReserved: Pointer; // void* optional
dwFlags: DWORD // DWORD
): BOOL; stdcall;
external 'WININET.dll' name 'GetUrlCacheEntryInfoExA';result := DllCall("WININET\GetUrlCacheEntryInfoExA"
, "AStr", lpszUrl ; LPCSTR
, "Ptr", lpCacheEntryInfo ; INTERNET_CACHE_ENTRY_INFOA* optional, in/out
, "Ptr", lpcbCacheEntryInfo ; DWORD* optional, in/out
, "Ptr", lpszRedirectUrl ; LPSTR optional
, "Ptr", lpcbRedirectUrl ; DWORD* optional
, "Ptr", lpReserved ; void* optional
, "UInt", dwFlags ; DWORD
, "Int") ; return: BOOL●GetUrlCacheEntryInfoExA(lpszUrl, lpCacheEntryInfo, lpcbCacheEntryInfo, lpszRedirectUrl, lpcbRedirectUrl, lpReserved, dwFlags) = DLL("WININET.dll", "bool GetUrlCacheEntryInfoExA(char*, void*, void*, char*, void*, void*, dword)")
# 呼び出し: GetUrlCacheEntryInfoExA(lpszUrl, lpCacheEntryInfo, lpcbCacheEntryInfo, lpszRedirectUrl, lpcbRedirectUrl, lpReserved, dwFlags)
# lpszUrl : LPCSTR -> "char*"
# lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "void*"
# lpcbCacheEntryInfo : DWORD* optional, in/out -> "void*"
# lpszRedirectUrl : LPSTR optional -> "char*"
# lpcbRedirectUrl : DWORD* optional -> "void*"
# lpReserved : void* optional -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。