RetrieveUrlCacheEntryFileW
関数シグネチャ
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL RetrieveUrlCacheEntryFileW(
LPCWSTR lpszUrlName,
INTERNET_CACHE_ENTRY_INFOW* lpCacheEntryInfo, // optional
DWORD* lpcbCacheEntryInfo,
DWORD dwReserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpszUrlName | LPCWSTR | in | キャッシュエントリに関連付けられたリソースの URL を含む文字列へのポインター。これは一意の名前である必要があります。名前文字列にはエスケープ文字を含めないでください。 |
| lpCacheEntryInfo | INTERNET_CACHE_ENTRY_INFOW* | inoutoptional | キャッシュエントリ情報バッファーへのポインター。バッファーが不十分な場合、この関数は ERROR_INSUFFICIENT_BUFFER を返し、 lpdwCacheEntryInfoBufferSize に必要なバイト数を設定します。 |
| lpcbCacheEntryInfo | DWORD* | inout | lpCacheEntryInfo バッファーのサイズをバイト単位で指定する符号なしロング整数変数へのポインター。関数が戻ると、この変数には実際に使用されたバッファーのサイズ(バイト単位)、またはキャッシュエントリファイルを取得するために必要なバイト数が格納されます。呼び出し元はこのパラメーターの戻り値を確認する必要があります。戻りサイズが渡したサイズ以下であれば、関連するすべてのデータが返されています。 |
| dwReserved | DWORD | optional | このパラメーターは予約されており、0 にする必要があります。 |
戻り値の型: BOOL
公式ドキュメント
指定された URL に関連付けられたキャッシュエントリファイルをロックします。(Unicode)
戻り値
成功した場合は TRUE を、それ以外の場合は FALSE を返します。拡張エラー情報を取得するには、 GetLastError を呼び出します。返される可能性のあるエラー値は次のとおりです。
| 戻りコード | 説明 |
|---|---|
| ソース名で指定されたキャッシュエントリがキャッシュストレージ内に見つかりません。 | |
| lpdwCacheEntryInfoBufferSize で指定された lpCacheEntryInfo バッファーのサイズが、すべての情報を格納するには不十分です。 lpdwCacheEntryInfoBufferSize に返される値は、すべての情報を取得するために必要なバッファーサイズを示します。 |
解説(Remarks)
RetrieveUrlCacheEntryFile は URL の解析を一切行わないため、アンカー (#) を含む URL は、たとえそのリソースがキャッシュされていてもキャッシュ内で見つかりません。たとえば、URL http://adatum.com/example.htm#sample が渡された場合、http://adatum.com/example.htm がキャッシュ内にあっても、この関数は ERROR_FILE_NOT_FOUND を返します。
ファイルは取得時に呼び出し元のためにロックされます。呼び出し元はファイルの使用が終わったら、そのファイルのロックを解除する必要があります。キャッシュマネージャーは一定の間隔が経過すると自動的にファイルのロックを解除します。ファイルがロックされている間、キャッシュマネージャーはそのファイルをキャッシュから削除しません。この関数が効率的に動作するかどうかは、キャッシュの内部実装に依存することに注意することが重要です。たとえば、URL データが他の URL のデータを含むパックされたファイルに格納されている場合、キャッシュはそのデータのコピーを、キャッシュが管理する一時ディレクトリ内のファイルに作成します。キャッシュは最終的にそのコピーを削除します。この関数は、アプリケーションを起動するためにファイル名が必要な状況でのみ使用することを推奨します。ほとんどの場合は RetrieveUrlCacheEntryStream と関連するストリーム関数を使用してください。
WinINet API の他のすべての側面と同様に、この関数を DllMain 内やグローバルオブジェクトのコンストラクター・デストラクター内から安全に呼び出すことはできません。
wininet.h ヘッダーは、RetrieveUrlCacheEntryFile を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、コンパイルエラーやランタイムエラーを引き起こす不一致につながる可能性があります。詳細については、関数プロトタイプの規則を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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 方式にも切替可。#uselib "WININET.dll" #cfunc global RetrieveUrlCacheEntryFileW "RetrieveUrlCacheEntryFileW" wstr, sptr, sptr, int ; res = RetrieveUrlCacheEntryFileW(lpszUrlName, varptr(lpCacheEntryInfo), varptr(lpcbCacheEntryInfo), dwReserved) ; lpszUrlName : LPCWSTR -> "wstr" ; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "sptr" ; lpcbCacheEntryInfo : DWORD* in/out -> "sptr" ; dwReserved : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; BOOL RetrieveUrlCacheEntryFileW(LPCWSTR lpszUrlName, INTERNET_CACHE_ENTRY_INFOW* lpCacheEntryInfo, DWORD* lpcbCacheEntryInfo, DWORD dwReserved) #uselib "WININET.dll" #cfunc global RetrieveUrlCacheEntryFileW "RetrieveUrlCacheEntryFileW" wstr, intptr, intptr, int ; res = RetrieveUrlCacheEntryFileW(lpszUrlName, varptr(lpCacheEntryInfo), varptr(lpcbCacheEntryInfo), dwReserved) ; lpszUrlName : LPCWSTR -> "wstr" ; lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "intptr" ; lpcbCacheEntryInfo : DWORD* in/out -> "intptr" ; dwReserved : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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 版の利用を推奨。const std = @import("std");
extern "wininet" fn RetrieveUrlCacheEntryFileW(
lpszUrlName: [*c]const u16, // LPCWSTR
lpCacheEntryInfo: [*c]INTERNET_CACHE_ENTRY_INFOW, // INTERNET_CACHE_ENTRY_INFOW* optional, in/out
lpcbCacheEntryInfo: [*c]u32, // DWORD* in/out
dwReserved: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc RetrieveUrlCacheEntryFileW(
lpszUrlName: WideCString, # LPCWSTR
lpCacheEntryInfo: ptr INTERNET_CACHE_ENTRY_INFOW, # INTERNET_CACHE_ENTRY_INFOW* optional, in/out
lpcbCacheEntryInfo: ptr uint32, # DWORD* in/out
dwReserved: uint32 # DWORD optional
): int32 {.importc: "RetrieveUrlCacheEntryFileW", stdcall, dynlib: "WININET.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "wininet");
extern(Windows)
int RetrieveUrlCacheEntryFileW(
const(wchar)* lpszUrlName, // LPCWSTR
INTERNET_CACHE_ENTRY_INFOW* lpCacheEntryInfo, // INTERNET_CACHE_ENTRY_INFOW* optional, in/out
uint* lpcbCacheEntryInfo, // DWORD* in/out
uint dwReserved // DWORD optional
);ccall((:RetrieveUrlCacheEntryFileW, "WININET.dll"), stdcall, Int32,
(Cwstring, Ptr{INTERNET_CACHE_ENTRY_INFOW}, Ptr{UInt32}, UInt32),
lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
# lpszUrlName : LPCWSTR -> Cwstring
# lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> Ptr{INTERNET_CACHE_ENTRY_INFOW}
# lpcbCacheEntryInfo : DWORD* in/out -> Ptr{UInt32}
# dwReserved : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t RetrieveUrlCacheEntryFileW(
const uint16_t* lpszUrlName,
void* lpCacheEntryInfo,
uint32_t* lpcbCacheEntryInfo,
uint32_t dwReserved);
]]
local wininet = ffi.load("wininet")
-- wininet.RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
-- lpszUrlName : LPCWSTR
-- lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out
-- lpcbCacheEntryInfo : DWORD* in/out
-- dwReserved : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const RetrieveUrlCacheEntryFileW = lib.func('__stdcall', 'RetrieveUrlCacheEntryFileW', 'int32_t', ['str16', 'void *', 'uint32_t *', 'uint32_t']);
// RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
// lpszUrlName : LPCWSTR -> 'str16'
// lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> 'void *'
// lpcbCacheEntryInfo : DWORD* in/out -> 'uint32_t *'
// dwReserved : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
RetrieveUrlCacheEntryFileW: { parameters: ["buffer", "pointer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved)
// lpszUrlName : LPCWSTR -> "buffer"
// lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "pointer"
// lpcbCacheEntryInfo : DWORD* in/out -> "pointer"
// dwReserved : DWORD optional -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RetrieveUrlCacheEntryFileW(
const uint16_t* lpszUrlName,
void* lpCacheEntryInfo,
uint32_t* lpcbCacheEntryInfo,
uint32_t dwReserved);
C, "WININET.dll");
// $ffi->RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo, lpcbCacheEntryInfo, dwReserved);
// lpszUrlName : LPCWSTR
// lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out
// lpcbCacheEntryInfo : DWORD* in/out
// dwReserved : DWORD optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wininet extends StdCallLibrary {
Wininet INSTANCE = Native.load("wininet", Wininet.class, W32APIOptions.UNICODE_OPTIONS);
boolean RetrieveUrlCacheEntryFileW(
WString lpszUrlName, // LPCWSTR
Pointer lpCacheEntryInfo, // INTERNET_CACHE_ENTRY_INFOW* optional, in/out
IntByReference lpcbCacheEntryInfo, // DWORD* in/out
int dwReserved // DWORD optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("wininet")]
lib LibWININET
fun RetrieveUrlCacheEntryFileW = RetrieveUrlCacheEntryFileW(
lpszUrlName : UInt16*, # LPCWSTR
lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW*, # INTERNET_CACHE_ENTRY_INFOW* optional, in/out
lpcbCacheEntryInfo : UInt32*, # DWORD* in/out
dwReserved : UInt32 # DWORD optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RetrieveUrlCacheEntryFileWNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Uint32>, Uint32);
typedef RetrieveUrlCacheEntryFileWDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Uint32>, int);
final RetrieveUrlCacheEntryFileW = DynamicLibrary.open('WININET.dll')
.lookupFunction<RetrieveUrlCacheEntryFileWNative, RetrieveUrlCacheEntryFileWDart>('RetrieveUrlCacheEntryFileW');
// lpszUrlName : LPCWSTR -> Pointer<Utf16>
// lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> Pointer<Void>
// lpcbCacheEntryInfo : DWORD* in/out -> Pointer<Uint32>
// dwReserved : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RetrieveUrlCacheEntryFileW"
c_RetrieveUrlCacheEntryFileW :: CWString -> Ptr () -> Ptr Word32 -> Word32 -> IO CInt
-- lpszUrlName : LPCWSTR -> CWString
-- lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> Ptr ()
-- lpcbCacheEntryInfo : DWORD* in/out -> Ptr Word32
-- dwReserved : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let retrieveurlcacheentryfilew =
foreign "RetrieveUrlCacheEntryFileW"
((ptr uint16_t) @-> (ptr void) @-> (ptr uint32_t) @-> uint32_t @-> returning int32_t)
(* lpszUrlName : LPCWSTR -> (ptr uint16_t) *)
(* lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> (ptr void) *)
(* lpcbCacheEntryInfo : DWORD* in/out -> (ptr uint32_t) *)
(* dwReserved : DWORD optional -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("RetrieveUrlCacheEntryFileW" retrieve-url-cache-entry-file-w :convention :stdcall) :int32
(lpsz-url-name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-cache-entry-info :pointer) ; INTERNET_CACHE_ENTRY_INFOW* optional, in/out
(lpcb-cache-entry-info :pointer) ; DWORD* in/out
(dw-reserved :uint32)) ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RetrieveUrlCacheEntryFileW = Win32::API::More->new('WININET',
'BOOL RetrieveUrlCacheEntryFileW(LPCWSTR lpszUrlName, LPVOID lpCacheEntryInfo, LPVOID lpcbCacheEntryInfo, DWORD dwReserved)');
# my $ret = $RetrieveUrlCacheEntryFileW->Call($lpszUrlName, $lpCacheEntryInfo, $lpcbCacheEntryInfo, $dwReserved);
# lpszUrlName : LPCWSTR -> LPCWSTR
# lpCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> LPVOID
# lpcbCacheEntryInfo : DWORD* in/out -> LPVOID
# dwReserved : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f RetrieveUrlCacheEntryFileA (ANSI版) — URLキャッシュエントリのファイルを取得しロックする(ANSI版)。