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

UrlCacheRetrieveEntryFile

関数
指定URLのキャッシュエントリファイルを取得する。
DLLWININET.dll呼出規約winapi

シグネチャ

// WININET.dll
#include <windows.h>

DWORD UrlCacheRetrieveEntryFile(
    void* hAppCache,   // optional
    LPCWSTR pcwszUrl,
    URLCACHE_ENTRY_INFO* pCacheEntryInfo,
    void** phEntryFile
);

パラメーター

名前方向説明
hAppCachevoid*inoptional対象のアプリケーションキャッシュハンドル。NULLでグローバルキャッシュ。
pcwszUrlLPCWSTRin取り出すエントリのURLを示すUnicode文字列。
pCacheEntryInfoURLCACHE_ENTRY_INFO*out取得したエントリ情報を受け取るURLCACHE_ENTRY_INFO構造体へのポインタ。
phEntryFilevoid**out取り出したエントリファイルのハンドルを受け取るvoid*ポインタへのポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

// WININET.dll
#include <windows.h>

DWORD UrlCacheRetrieveEntryFile(
    void* hAppCache,   // optional
    LPCWSTR pcwszUrl,
    URLCACHE_ENTRY_INFO* pCacheEntryInfo,
    void** phEntryFile
);
[DllImport("WININET.dll", ExactSpelling = true)]
static extern uint UrlCacheRetrieveEntryFile(
    IntPtr hAppCache,   // void* optional
    [MarshalAs(UnmanagedType.LPWStr)] string pcwszUrl,   // LPCWSTR
    IntPtr pCacheEntryInfo,   // URLCACHE_ENTRY_INFO* out
    IntPtr phEntryFile   // void** out
);
<DllImport("WININET.dll", ExactSpelling:=True)>
Public Shared Function UrlCacheRetrieveEntryFile(
    hAppCache As IntPtr,   ' void* optional
    <MarshalAs(UnmanagedType.LPWStr)> pcwszUrl As String,   ' LPCWSTR
    pCacheEntryInfo As IntPtr,   ' URLCACHE_ENTRY_INFO* out
    phEntryFile As IntPtr   ' void** out
) As UInteger
End Function
' hAppCache : void* optional
' pcwszUrl : LPCWSTR
' pCacheEntryInfo : URLCACHE_ENTRY_INFO* out
' phEntryFile : void** out
Declare PtrSafe Function UrlCacheRetrieveEntryFile Lib "wininet" ( _
    ByVal hAppCache As LongPtr, _
    ByVal pcwszUrl As LongPtr, _
    ByVal pCacheEntryInfo As LongPtr, _
    ByVal phEntryFile As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UrlCacheRetrieveEntryFile = ctypes.windll.wininet.UrlCacheRetrieveEntryFile
UrlCacheRetrieveEntryFile.restype = wintypes.DWORD
UrlCacheRetrieveEntryFile.argtypes = [
    ctypes.POINTER(None),  # hAppCache : void* optional
    wintypes.LPCWSTR,  # pcwszUrl : LPCWSTR
    ctypes.c_void_p,  # pCacheEntryInfo : URLCACHE_ENTRY_INFO* out
    ctypes.c_void_p,  # phEntryFile : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
UrlCacheRetrieveEntryFile = Fiddle::Function.new(
  lib['UrlCacheRetrieveEntryFile'],
  [
    Fiddle::TYPE_VOIDP,  # hAppCache : void* optional
    Fiddle::TYPE_VOIDP,  # pcwszUrl : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pCacheEntryInfo : URLCACHE_ENTRY_INFO* out
    Fiddle::TYPE_VOIDP,  # phEntryFile : void** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wininet")]
extern "system" {
    fn UrlCacheRetrieveEntryFile(
        hAppCache: *mut (),  // void* optional
        pcwszUrl: *const u16,  // LPCWSTR
        pCacheEntryInfo: *mut URLCACHE_ENTRY_INFO,  // URLCACHE_ENTRY_INFO* out
        phEntryFile: *mut *mut ()  // void** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WININET.dll")]
public static extern uint UrlCacheRetrieveEntryFile(IntPtr hAppCache, [MarshalAs(UnmanagedType.LPWStr)] string pcwszUrl, IntPtr pCacheEntryInfo, IntPtr phEntryFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_UrlCacheRetrieveEntryFile' -Namespace Win32 -PassThru
# $api::UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile)
#uselib "WININET.dll"
#func global UrlCacheRetrieveEntryFile "UrlCacheRetrieveEntryFile" sptr, sptr, sptr, sptr
; UrlCacheRetrieveEntryFile hAppCache, pcwszUrl, varptr(pCacheEntryInfo), phEntryFile   ; 戻り値は stat
; hAppCache : void* optional -> "sptr"
; pcwszUrl : LPCWSTR -> "sptr"
; pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> "sptr"
; phEntryFile : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global UrlCacheRetrieveEntryFile "UrlCacheRetrieveEntryFile" sptr, wstr, var, sptr
; res = UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile)
; hAppCache : void* optional -> "sptr"
; pcwszUrl : LPCWSTR -> "wstr"
; pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> "var"
; phEntryFile : void** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD UrlCacheRetrieveEntryFile(void* hAppCache, LPCWSTR pcwszUrl, URLCACHE_ENTRY_INFO* pCacheEntryInfo, void** phEntryFile)
#uselib "WININET.dll"
#cfunc global UrlCacheRetrieveEntryFile "UrlCacheRetrieveEntryFile" intptr, wstr, var, intptr
; res = UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile)
; hAppCache : void* optional -> "intptr"
; pcwszUrl : LPCWSTR -> "wstr"
; pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> "var"
; phEntryFile : void** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procUrlCacheRetrieveEntryFile = wininet.NewProc("UrlCacheRetrieveEntryFile")
)

// hAppCache (void* optional), pcwszUrl (LPCWSTR), pCacheEntryInfo (URLCACHE_ENTRY_INFO* out), phEntryFile (void** out)
r1, _, err := procUrlCacheRetrieveEntryFile.Call(
	uintptr(hAppCache),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwszUrl))),
	uintptr(pCacheEntryInfo),
	uintptr(phEntryFile),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function UrlCacheRetrieveEntryFile(
  hAppCache: Pointer;   // void* optional
  pcwszUrl: PWideChar;   // LPCWSTR
  pCacheEntryInfo: Pointer;   // URLCACHE_ENTRY_INFO* out
  phEntryFile: Pointer   // void** out
): DWORD; stdcall;
  external 'WININET.dll' name 'UrlCacheRetrieveEntryFile';
result := DllCall("WININET\UrlCacheRetrieveEntryFile"
    , "Ptr", hAppCache   ; void* optional
    , "WStr", pcwszUrl   ; LPCWSTR
    , "Ptr", pCacheEntryInfo   ; URLCACHE_ENTRY_INFO* out
    , "Ptr", phEntryFile   ; void** out
    , "UInt")   ; return: DWORD
●UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile) = DLL("WININET.dll", "dword UrlCacheRetrieveEntryFile(void*, char*, void*, void*)")
# 呼び出し: UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile)
# hAppCache : void* optional -> "void*"
# pcwszUrl : LPCWSTR -> "char*"
# pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> "void*"
# phEntryFile : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wininet" fn UrlCacheRetrieveEntryFile(
    hAppCache: ?*anyopaque, // void* optional
    pcwszUrl: [*c]const u16, // LPCWSTR
    pCacheEntryInfo: [*c]URLCACHE_ENTRY_INFO, // URLCACHE_ENTRY_INFO* out
    phEntryFile: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) u32;
proc UrlCacheRetrieveEntryFile(
    hAppCache: pointer,  # void* optional
    pcwszUrl: WideCString,  # LPCWSTR
    pCacheEntryInfo: ptr URLCACHE_ENTRY_INFO,  # URLCACHE_ENTRY_INFO* out
    phEntryFile: pointer  # void** out
): uint32 {.importc: "UrlCacheRetrieveEntryFile", stdcall, dynlib: "WININET.dll".}
pragma(lib, "wininet");
extern(Windows)
uint UrlCacheRetrieveEntryFile(
    void* hAppCache,   // void* optional
    const(wchar)* pcwszUrl,   // LPCWSTR
    URLCACHE_ENTRY_INFO* pCacheEntryInfo,   // URLCACHE_ENTRY_INFO* out
    void** phEntryFile   // void** out
);
ccall((:UrlCacheRetrieveEntryFile, "WININET.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Cwstring, Ptr{URLCACHE_ENTRY_INFO}, Ptr{Cvoid}),
      hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile)
# hAppCache : void* optional -> Ptr{Cvoid}
# pcwszUrl : LPCWSTR -> Cwstring
# pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> Ptr{URLCACHE_ENTRY_INFO}
# phEntryFile : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t UrlCacheRetrieveEntryFile(
    void* hAppCache,
    const uint16_t* pcwszUrl,
    void* pCacheEntryInfo,
    void** phEntryFile);
]]
local wininet = ffi.load("wininet")
-- wininet.UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile)
-- hAppCache : void* optional
-- pcwszUrl : LPCWSTR
-- pCacheEntryInfo : URLCACHE_ENTRY_INFO* out
-- phEntryFile : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const UrlCacheRetrieveEntryFile = lib.func('__stdcall', 'UrlCacheRetrieveEntryFile', 'uint32_t', ['void *', 'str16', 'void *', 'void *']);
// UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile)
// hAppCache : void* optional -> 'void *'
// pcwszUrl : LPCWSTR -> 'str16'
// pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> 'void *'
// phEntryFile : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WININET.dll", {
  UrlCacheRetrieveEntryFile: { parameters: ["pointer", "buffer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile)
// hAppCache : void* optional -> "pointer"
// pcwszUrl : LPCWSTR -> "buffer"
// pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> "pointer"
// phEntryFile : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t UrlCacheRetrieveEntryFile(
    void* hAppCache,
    const uint16_t* pcwszUrl,
    void* pCacheEntryInfo,
    void** phEntryFile);
C, "WININET.dll");
// $ffi->UrlCacheRetrieveEntryFile(hAppCache, pcwszUrl, pCacheEntryInfo, phEntryFile);
// hAppCache : void* optional
// pcwszUrl : LPCWSTR
// pCacheEntryInfo : URLCACHE_ENTRY_INFO* out
// phEntryFile : void** out
// 構造体/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);
    int UrlCacheRetrieveEntryFile(
        Pointer hAppCache,   // void* optional
        WString pcwszUrl,   // LPCWSTR
        Pointer pCacheEntryInfo,   // URLCACHE_ENTRY_INFO* out
        Pointer phEntryFile   // void** out
    );
}
@[Link("wininet")]
lib LibWININET
  fun UrlCacheRetrieveEntryFile = UrlCacheRetrieveEntryFile(
    hAppCache : Void*,   # void* optional
    pcwszUrl : UInt16*,   # LPCWSTR
    pCacheEntryInfo : URLCACHE_ENTRY_INFO*,   # URLCACHE_ENTRY_INFO* out
    phEntryFile : Void**   # void** out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef UrlCacheRetrieveEntryFileNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef UrlCacheRetrieveEntryFileDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final UrlCacheRetrieveEntryFile = DynamicLibrary.open('WININET.dll')
    .lookupFunction<UrlCacheRetrieveEntryFileNative, UrlCacheRetrieveEntryFileDart>('UrlCacheRetrieveEntryFile');
// hAppCache : void* optional -> Pointer<Void>
// pcwszUrl : LPCWSTR -> Pointer<Utf16>
// pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> Pointer<Void>
// phEntryFile : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function UrlCacheRetrieveEntryFile(
  hAppCache: Pointer;   // void* optional
  pcwszUrl: PWideChar;   // LPCWSTR
  pCacheEntryInfo: Pointer;   // URLCACHE_ENTRY_INFO* out
  phEntryFile: Pointer   // void** out
): DWORD; stdcall;
  external 'WININET.dll' name 'UrlCacheRetrieveEntryFile';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "UrlCacheRetrieveEntryFile"
  c_UrlCacheRetrieveEntryFile :: Ptr () -> CWString -> Ptr () -> Ptr () -> IO Word32
-- hAppCache : void* optional -> Ptr ()
-- pcwszUrl : LPCWSTR -> CWString
-- pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> Ptr ()
-- phEntryFile : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let urlcacheretrieveentryfile =
  foreign "UrlCacheRetrieveEntryFile"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* hAppCache : void* optional -> (ptr void) *)
(* pcwszUrl : LPCWSTR -> (ptr uint16_t) *)
(* pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> (ptr void) *)
(* phEntryFile : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)

(cffi:defcfun ("UrlCacheRetrieveEntryFile" url-cache-retrieve-entry-file :convention :stdcall) :uint32
  (h-app-cache :pointer)   ; void* optional
  (pcwsz-url (:string :encoding :utf-16le))   ; LPCWSTR
  (p-cache-entry-info :pointer)   ; URLCACHE_ENTRY_INFO* out
  (ph-entry-file :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $UrlCacheRetrieveEntryFile = Win32::API::More->new('WININET',
    'DWORD UrlCacheRetrieveEntryFile(LPVOID hAppCache, LPCWSTR pcwszUrl, LPVOID pCacheEntryInfo, LPVOID phEntryFile)');
# my $ret = $UrlCacheRetrieveEntryFile->Call($hAppCache, $pcwszUrl, $pCacheEntryInfo, $phEntryFile);
# hAppCache : void* optional -> LPVOID
# pcwszUrl : LPCWSTR -> LPCWSTR
# pCacheEntryInfo : URLCACHE_ENTRY_INFO* out -> LPVOID
# phEntryFile : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型