Win32 API 日本語リファレンス
ホームNetworking.WinInet › RetrieveUrlCacheEntryFileA

RetrieveUrlCacheEntryFileA

関数
URLキャッシュエントリのファイルを取得しロックする(ANSI版)。
DLLWININET.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL RetrieveUrlCacheEntryFileA(
    LPCSTR lpszUrlName,
    INTERNET_CACHE_ENTRY_INFOA* lpCacheEntryInfo,   // optional
    DWORD* lpcbCacheEntryInfo,
    DWORD dwReserved   // optional
);

パラメーター

名前方向
lpszUrlNameLPCSTRin
lpCacheEntryInfoINTERNET_CACHE_ENTRY_INFOA*inoutoptional
lpcbCacheEntryInfoDWORD*inout
dwReservedDWORDoptional

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL RetrieveUrlCacheEntryFileA(
    LPCSTR lpszUrlName,
    INTERNET_CACHE_ENTRY_INFOA* lpCacheEntryInfo,   // optional
    DWORD* lpcbCacheEntryInfo,
    DWORD dwReserved   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool RetrieveUrlCacheEntryFileA(
    [MarshalAs(UnmanagedType.LPStr)] string lpszUrlName,   // LPCSTR
    IntPtr lpCacheEntryInfo,   // INTERNET_CACHE_ENTRY_INFOA* optional, in/out
    ref uint lpcbCacheEntryInfo,   // DWORD* in/out
    uint dwReserved   // DWORD optional
);
<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function RetrieveUrlCacheEntryFileA(
    <MarshalAs(UnmanagedType.LPStr)> lpszUrlName As String,   ' LPCSTR
    lpCacheEntryInfo As IntPtr,   ' INTERNET_CACHE_ENTRY_INFOA* optional, in/out
    ByRef lpcbCacheEntryInfo As UInteger,   ' DWORD* in/out
    dwReserved As UInteger   ' DWORD optional
) As Boolean
End Function
' lpszUrlName : LPCSTR
' lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out
' lpcbCacheEntryInfo : DWORD* in/out
' dwReserved : DWORD optional
Declare PtrSafe Function RetrieveUrlCacheEntryFileA Lib "wininet" ( _
    ByVal lpszUrlName As String, _
    ByVal lpCacheEntryInfo As LongPtr, _
    ByRef lpcbCacheEntryInfo As Long, _
    ByVal dwReserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RetrieveUrlCacheEntryFileA = ctypes.windll.wininet.RetrieveUrlCacheEntryFileA
RetrieveUrlCacheEntryFileA.restype = wintypes.BOOL
RetrieveUrlCacheEntryFileA.argtypes = [
    wintypes.LPCSTR,  # lpszUrlName : LPCSTR
    ctypes.c_void_p,  # lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out
    ctypes.POINTER(wintypes.DWORD),  # lpcbCacheEntryInfo : DWORD* in/out
    wintypes.DWORD,  # dwReserved : DWORD optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
RetrieveUrlCacheEntryFileA = Fiddle::Function.new(
  lib['RetrieveUrlCacheEntryFileA'],
  [
    Fiddle::TYPE_VOIDP,  # lpszUrlName : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out
    Fiddle::TYPE_VOIDP,  # lpcbCacheEntryInfo : DWORD* in/out
    -Fiddle::TYPE_INT,  # dwReserved : DWORD optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "wininet")]
extern "system" {
    fn RetrieveUrlCacheEntryFileA(
        lpszUrlName: *const u8,  // LPCSTR
        lpCacheEntryInfo: *mut INTERNET_CACHE_ENTRY_INFOA,  // INTERNET_CACHE_ENTRY_INFOA* optional, in/out
        lpcbCacheEntryInfo: *mut u32,  // DWORD* in/out
        dwReserved: u32  // DWORD optional
    ) -> 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 RetrieveUrlCacheEntryFileA([MarshalAs(UnmanagedType.LPStr)] string lpszUrlName, IntPtr lpCacheEntryInfo, ref uint lpcbCacheEntryInfo, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_RetrieveUrlCacheEntryFileA' -Namespace Win32 -PassThru
# $api::RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
#uselib "WININET.dll"
#func global RetrieveUrlCacheEntryFileA "RetrieveUrlCacheEntryFileA" sptr, sptr, sptr, sptr
; RetrieveUrlCacheEntryFileA lpszUrlName, varptr(lpCacheEntryInfo), varptr(lpcbCacheEntryInfo), dwReserved   ; 戻り値は stat
; lpszUrlName : LPCSTR -> "sptr"
; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "sptr"
; lpcbCacheEntryInfo : DWORD* in/out -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global RetrieveUrlCacheEntryFileA "RetrieveUrlCacheEntryFileA" str, var, var, int
; res = RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
; lpszUrlName : LPCSTR -> "str"
; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "var"
; lpcbCacheEntryInfo : DWORD* in/out -> "var"
; dwReserved : DWORD optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL RetrieveUrlCacheEntryFileA(LPCSTR lpszUrlName, INTERNET_CACHE_ENTRY_INFOA* lpCacheEntryInfo, DWORD* lpcbCacheEntryInfo, DWORD dwReserved)
#uselib "WININET.dll"
#cfunc global RetrieveUrlCacheEntryFileA "RetrieveUrlCacheEntryFileA" str, var, var, int
; res = RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
; lpszUrlName : LPCSTR -> "str"
; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "var"
; lpcbCacheEntryInfo : DWORD* in/out -> "var"
; dwReserved : DWORD optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procRetrieveUrlCacheEntryFileA = wininet.NewProc("RetrieveUrlCacheEntryFileA")
)

// lpszUrlName (LPCSTR), lpCacheEntryInfo (INTERNET_CACHE_ENTRY_INFOA* optional, in/out), lpcbCacheEntryInfo (DWORD* in/out), dwReserved (DWORD optional)
r1, _, err := procRetrieveUrlCacheEntryFileA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszUrlName))),
	uintptr(lpCacheEntryInfo),
	uintptr(lpcbCacheEntryInfo),
	uintptr(dwReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function RetrieveUrlCacheEntryFileA(
  lpszUrlName: PAnsiChar;   // LPCSTR
  lpCacheEntryInfo: Pointer;   // INTERNET_CACHE_ENTRY_INFOA* optional, in/out
  lpcbCacheEntryInfo: Pointer;   // DWORD* in/out
  dwReserved: DWORD   // DWORD optional
): BOOL; stdcall;
  external 'WININET.dll' name 'RetrieveUrlCacheEntryFileA';
result := DllCall("WININET\RetrieveUrlCacheEntryFileA"
    , "AStr", lpszUrlName   ; LPCSTR
    , "Ptr", lpCacheEntryInfo   ; INTERNET_CACHE_ENTRY_INFOA* optional, in/out
    , "Ptr", lpcbCacheEntryInfo   ; DWORD* in/out
    , "UInt", dwReserved   ; DWORD optional
    , "Int")   ; return: BOOL
●RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved) = DLL("WININET.dll", "bool RetrieveUrlCacheEntryFileA(char*, void*, void*, dword)")
# 呼び出し: RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
# lpszUrlName : LPCSTR -> "char*"
# lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOA* optional, in/out -> "void*"
# lpcbCacheEntryInfo : DWORD* in/out -> "void*"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。