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

RetrieveUrlCacheEntryFileW

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

シグネチャ

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL RetrieveUrlCacheEntryFileW(
    LPCWSTR lpszUrlName,
    INTERNET_CACHE_ENTRY_INFOW* lpCacheEntryInfo,   // optional
    DWORD* lpcbCacheEntryInfo,
    DWORD dwReserved   // optional
);

パラメーター

名前方向
lpszUrlNameLPCWSTRin
lpCacheEntryInfoINTERNET_CACHE_ENTRY_INFOW*inoutoptional
lpcbCacheEntryInfoDWORD*inout
dwReservedDWORDoptional

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL RetrieveUrlCacheEntryFileW(
    LPCWSTR lpszUrlName,
    INTERNET_CACHE_ENTRY_INFOW* lpCacheEntryInfo,   // optional
    DWORD* lpcbCacheEntryInfo,
    DWORD dwReserved   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool RetrieveUrlCacheEntryFileW(
    [MarshalAs(UnmanagedType.LPWStr)] string lpszUrlName,   // LPCWSTR
    IntPtr lpCacheEntryInfo,   // INTERNET_CACHE_ENTRY_INFOW* optional, in/out
    ref uint lpcbCacheEntryInfo,   // DWORD* in/out
    uint dwReserved   // DWORD optional
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function RetrieveUrlCacheEntryFileW(
    <MarshalAs(UnmanagedType.LPWStr)> lpszUrlName As String,   ' LPCWSTR
    lpCacheEntryInfo As IntPtr,   ' INTERNET_CACHE_ENTRY_INFOW* optional, in/out
    ByRef lpcbCacheEntryInfo As UInteger,   ' DWORD* in/out
    dwReserved As UInteger   ' DWORD optional
) As Boolean
End Function
' lpszUrlName : LPCWSTR
' lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out
' lpcbCacheEntryInfo : DWORD* in/out
' dwReserved : DWORD optional
Declare PtrSafe Function RetrieveUrlCacheEntryFileW Lib "wininet" ( _
    ByVal lpszUrlName As LongPtr, _
    ByVal lpCacheEntryInfo As LongPtr, _
    ByRef lpcbCacheEntryInfo As Long, _
    ByVal dwReserved As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RetrieveUrlCacheEntryFileW = ctypes.windll.wininet.RetrieveUrlCacheEntryFileW
RetrieveUrlCacheEntryFileW.restype = wintypes.BOOL
RetrieveUrlCacheEntryFileW.argtypes = [
    wintypes.LPCWSTR,  # lpszUrlName : LPCWSTR
    ctypes.c_void_p,  # lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* 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')
RetrieveUrlCacheEntryFileW = Fiddle::Function.new(
  lib['RetrieveUrlCacheEntryFileW'],
  [
    Fiddle::TYPE_VOIDP,  # lpszUrlName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out
    Fiddle::TYPE_VOIDP,  # lpcbCacheEntryInfo : DWORD* in/out
    -Fiddle::TYPE_INT,  # dwReserved : DWORD optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn RetrieveUrlCacheEntryFileW(
        lpszUrlName: *const u16,  // LPCWSTR
        lpCacheEntryInfo: *mut INTERNET_CACHE_ENTRY_INFOW,  // INTERNET_CACHE_ENTRY_INFOW* 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.Unicode, SetLastError = true)]
public static extern bool RetrieveUrlCacheEntryFileW([MarshalAs(UnmanagedType.LPWStr)] string lpszUrlName, IntPtr lpCacheEntryInfo, ref uint lpcbCacheEntryInfo, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_RetrieveUrlCacheEntryFileW' -Namespace Win32 -PassThru
# $api::RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
#uselib "WININET.dll"
#func global RetrieveUrlCacheEntryFileW "RetrieveUrlCacheEntryFileW" wptr, wptr, wptr, wptr
; RetrieveUrlCacheEntryFileW lpszUrlName, varptr(lpCacheEntryInfo), varptr(lpcbCacheEntryInfo), dwReserved   ; 戻り値は stat
; lpszUrlName : LPCWSTR -> "wptr"
; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "wptr"
; lpcbCacheEntryInfo : DWORD* in/out -> "wptr"
; dwReserved : DWORD optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global RetrieveUrlCacheEntryFileW "RetrieveUrlCacheEntryFileW" wstr, var, var, int
; res = RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
; lpszUrlName : LPCWSTR -> "wstr"
; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "var"
; lpcbCacheEntryInfo : DWORD* in/out -> "var"
; dwReserved : DWORD optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL RetrieveUrlCacheEntryFileW(LPCWSTR lpszUrlName, INTERNET_CACHE_ENTRY_INFOW* lpCacheEntryInfo, DWORD* lpcbCacheEntryInfo, DWORD dwReserved)
#uselib "WININET.dll"
#cfunc global RetrieveUrlCacheEntryFileW "RetrieveUrlCacheEntryFileW" wstr, var, var, int
; res = RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
; lpszUrlName : LPCWSTR -> "wstr"
; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* 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")
	procRetrieveUrlCacheEntryFileW = wininet.NewProc("RetrieveUrlCacheEntryFileW")
)

// lpszUrlName (LPCWSTR), lpCacheEntryInfo (INTERNET_CACHE_ENTRY_INFOW* optional, in/out), lpcbCacheEntryInfo (DWORD* in/out), dwReserved (DWORD optional)
r1, _, err := procRetrieveUrlCacheEntryFileW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszUrlName))),
	uintptr(lpCacheEntryInfo),
	uintptr(lpcbCacheEntryInfo),
	uintptr(dwReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function RetrieveUrlCacheEntryFileW(
  lpszUrlName: PWideChar;   // LPCWSTR
  lpCacheEntryInfo: Pointer;   // INTERNET_CACHE_ENTRY_INFOW* optional, in/out
  lpcbCacheEntryInfo: Pointer;   // DWORD* in/out
  dwReserved: DWORD   // DWORD optional
): BOOL; stdcall;
  external 'WININET.dll' name 'RetrieveUrlCacheEntryFileW';
result := DllCall("WININET\RetrieveUrlCacheEntryFileW"
    , "WStr", lpszUrlName   ; LPCWSTR
    , "Ptr", lpCacheEntryInfo   ; INTERNET_CACHE_ENTRY_INFOW* optional, in/out
    , "Ptr", lpcbCacheEntryInfo   ; DWORD* in/out
    , "UInt", dwReserved   ; DWORD optional
    , "Int")   ; return: BOOL
●RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved) = DLL("WININET.dll", "bool RetrieveUrlCacheEntryFileW(char*, void*, void*, dword)")
# 呼び出し: RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
# lpszUrlName : LPCWSTR -> "char*"
# lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "void*"
# lpcbCacheEntryInfo : DWORD* in/out -> "void*"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。