ホーム › Networking.WinInet › UrlCacheGetEntryInfo
UrlCacheGetEntryInfo
関数指定URLのキャッシュエントリ情報を取得する。
シグネチャ
// WININET.dll
#include <windows.h>
DWORD UrlCacheGetEntryInfo(
void* hAppCache, // optional
LPCWSTR pcwszUrl,
URLCACHE_ENTRY_INFO* pCacheEntryInfo // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hAppCache | void* | inoptional | 対象のアプリケーションキャッシュハンドル。NULLでグローバルキャッシュ。 |
| pcwszUrl | LPCWSTR | in | 情報を取得するエントリのURLを示すUnicode文字列。 |
| pCacheEntryInfo | URLCACHE_ENTRY_INFO* | outoptional | 取得したエントリ情報を受け取るURLCACHE_ENTRY_INFO構造体へのポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// WININET.dll
#include <windows.h>
DWORD UrlCacheGetEntryInfo(
void* hAppCache, // optional
LPCWSTR pcwszUrl,
URLCACHE_ENTRY_INFO* pCacheEntryInfo // optional
);[DllImport("WININET.dll", ExactSpelling = true)]
static extern uint UrlCacheGetEntryInfo(
IntPtr hAppCache, // void* optional
[MarshalAs(UnmanagedType.LPWStr)] string pcwszUrl, // LPCWSTR
IntPtr pCacheEntryInfo // URLCACHE_ENTRY_INFO* optional, out
);<DllImport("WININET.dll", ExactSpelling:=True)>
Public Shared Function UrlCacheGetEntryInfo(
hAppCache As IntPtr, ' void* optional
<MarshalAs(UnmanagedType.LPWStr)> pcwszUrl As String, ' LPCWSTR
pCacheEntryInfo As IntPtr ' URLCACHE_ENTRY_INFO* optional, out
) As UInteger
End Function' hAppCache : void* optional
' pcwszUrl : LPCWSTR
' pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out
Declare PtrSafe Function UrlCacheGetEntryInfo Lib "wininet" ( _
ByVal hAppCache As LongPtr, _
ByVal pcwszUrl As LongPtr, _
ByVal pCacheEntryInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UrlCacheGetEntryInfo = ctypes.windll.wininet.UrlCacheGetEntryInfo
UrlCacheGetEntryInfo.restype = wintypes.DWORD
UrlCacheGetEntryInfo.argtypes = [
ctypes.POINTER(None), # hAppCache : void* optional
wintypes.LPCWSTR, # pcwszUrl : LPCWSTR
ctypes.c_void_p, # pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
UrlCacheGetEntryInfo = Fiddle::Function.new(
lib['UrlCacheGetEntryInfo'],
[
Fiddle::TYPE_VOIDP, # hAppCache : void* optional
Fiddle::TYPE_VOIDP, # pcwszUrl : LPCWSTR
Fiddle::TYPE_VOIDP, # pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out
],
-Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn UrlCacheGetEntryInfo(
hAppCache: *mut (), // void* optional
pcwszUrl: *const u16, // LPCWSTR
pCacheEntryInfo: *mut URLCACHE_ENTRY_INFO // URLCACHE_ENTRY_INFO* optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WININET.dll")]
public static extern uint UrlCacheGetEntryInfo(IntPtr hAppCache, [MarshalAs(UnmanagedType.LPWStr)] string pcwszUrl, IntPtr pCacheEntryInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_UrlCacheGetEntryInfo' -Namespace Win32 -PassThru
# $api::UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo)#uselib "WININET.dll"
#func global UrlCacheGetEntryInfo "UrlCacheGetEntryInfo" sptr, sptr, sptr
; UrlCacheGetEntryInfo hAppCache, pcwszUrl, varptr(pCacheEntryInfo) ; 戻り値は stat
; hAppCache : void* optional -> "sptr"
; pcwszUrl : LPCWSTR -> "sptr"
; pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global UrlCacheGetEntryInfo "UrlCacheGetEntryInfo" sptr, wstr, var ; res = UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo) ; hAppCache : void* optional -> "sptr" ; pcwszUrl : LPCWSTR -> "wstr" ; pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global UrlCacheGetEntryInfo "UrlCacheGetEntryInfo" sptr, wstr, sptr ; res = UrlCacheGetEntryInfo(hAppCache, pcwszUrl, varptr(pCacheEntryInfo)) ; hAppCache : void* optional -> "sptr" ; pcwszUrl : LPCWSTR -> "wstr" ; pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD UrlCacheGetEntryInfo(void* hAppCache, LPCWSTR pcwszUrl, URLCACHE_ENTRY_INFO* pCacheEntryInfo) #uselib "WININET.dll" #cfunc global UrlCacheGetEntryInfo "UrlCacheGetEntryInfo" intptr, wstr, var ; res = UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo) ; hAppCache : void* optional -> "intptr" ; pcwszUrl : LPCWSTR -> "wstr" ; pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD UrlCacheGetEntryInfo(void* hAppCache, LPCWSTR pcwszUrl, URLCACHE_ENTRY_INFO* pCacheEntryInfo) #uselib "WININET.dll" #cfunc global UrlCacheGetEntryInfo "UrlCacheGetEntryInfo" intptr, wstr, intptr ; res = UrlCacheGetEntryInfo(hAppCache, pcwszUrl, varptr(pCacheEntryInfo)) ; hAppCache : void* optional -> "intptr" ; pcwszUrl : LPCWSTR -> "wstr" ; pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procUrlCacheGetEntryInfo = wininet.NewProc("UrlCacheGetEntryInfo")
)
// hAppCache (void* optional), pcwszUrl (LPCWSTR), pCacheEntryInfo (URLCACHE_ENTRY_INFO* optional, out)
r1, _, err := procUrlCacheGetEntryInfo.Call(
uintptr(hAppCache),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwszUrl))),
uintptr(pCacheEntryInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction UrlCacheGetEntryInfo(
hAppCache: Pointer; // void* optional
pcwszUrl: PWideChar; // LPCWSTR
pCacheEntryInfo: Pointer // URLCACHE_ENTRY_INFO* optional, out
): DWORD; stdcall;
external 'WININET.dll' name 'UrlCacheGetEntryInfo';result := DllCall("WININET\UrlCacheGetEntryInfo"
, "Ptr", hAppCache ; void* optional
, "WStr", pcwszUrl ; LPCWSTR
, "Ptr", pCacheEntryInfo ; URLCACHE_ENTRY_INFO* optional, out
, "UInt") ; return: DWORD●UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo) = DLL("WININET.dll", "dword UrlCacheGetEntryInfo(void*, char*, void*)")
# 呼び出し: UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo)
# hAppCache : void* optional -> "void*"
# pcwszUrl : LPCWSTR -> "char*"
# pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wininet" fn UrlCacheGetEntryInfo(
hAppCache: ?*anyopaque, // void* optional
pcwszUrl: [*c]const u16, // LPCWSTR
pCacheEntryInfo: [*c]URLCACHE_ENTRY_INFO // URLCACHE_ENTRY_INFO* optional, out
) callconv(std.os.windows.WINAPI) u32;proc UrlCacheGetEntryInfo(
hAppCache: pointer, # void* optional
pcwszUrl: WideCString, # LPCWSTR
pCacheEntryInfo: ptr URLCACHE_ENTRY_INFO # URLCACHE_ENTRY_INFO* optional, out
): uint32 {.importc: "UrlCacheGetEntryInfo", stdcall, dynlib: "WININET.dll".}pragma(lib, "wininet");
extern(Windows)
uint UrlCacheGetEntryInfo(
void* hAppCache, // void* optional
const(wchar)* pcwszUrl, // LPCWSTR
URLCACHE_ENTRY_INFO* pCacheEntryInfo // URLCACHE_ENTRY_INFO* optional, out
);ccall((:UrlCacheGetEntryInfo, "WININET.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cwstring, Ptr{URLCACHE_ENTRY_INFO}),
hAppCache, pcwszUrl, pCacheEntryInfo)
# hAppCache : void* optional -> Ptr{Cvoid}
# pcwszUrl : LPCWSTR -> Cwstring
# pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> Ptr{URLCACHE_ENTRY_INFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t UrlCacheGetEntryInfo(
void* hAppCache,
const uint16_t* pcwszUrl,
void* pCacheEntryInfo);
]]
local wininet = ffi.load("wininet")
-- wininet.UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo)
-- hAppCache : void* optional
-- pcwszUrl : LPCWSTR
-- pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const UrlCacheGetEntryInfo = lib.func('__stdcall', 'UrlCacheGetEntryInfo', 'uint32_t', ['void *', 'str16', 'void *']);
// UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo)
// hAppCache : void* optional -> 'void *'
// pcwszUrl : LPCWSTR -> 'str16'
// pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
UrlCacheGetEntryInfo: { parameters: ["pointer", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo)
// hAppCache : void* optional -> "pointer"
// pcwszUrl : LPCWSTR -> "buffer"
// pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t UrlCacheGetEntryInfo(
void* hAppCache,
const uint16_t* pcwszUrl,
void* pCacheEntryInfo);
C, "WININET.dll");
// $ffi->UrlCacheGetEntryInfo(hAppCache, pcwszUrl, pCacheEntryInfo);
// hAppCache : void* optional
// pcwszUrl : LPCWSTR
// pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, 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 UrlCacheGetEntryInfo(
Pointer hAppCache, // void* optional
WString pcwszUrl, // LPCWSTR
Pointer pCacheEntryInfo // URLCACHE_ENTRY_INFO* optional, out
);
}@[Link("wininet")]
lib LibWININET
fun UrlCacheGetEntryInfo = UrlCacheGetEntryInfo(
hAppCache : Void*, # void* optional
pcwszUrl : UInt16*, # LPCWSTR
pCacheEntryInfo : URLCACHE_ENTRY_INFO* # URLCACHE_ENTRY_INFO* optional, out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UrlCacheGetEntryInfoNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
typedef UrlCacheGetEntryInfoDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
final UrlCacheGetEntryInfo = DynamicLibrary.open('WININET.dll')
.lookupFunction<UrlCacheGetEntryInfoNative, UrlCacheGetEntryInfoDart>('UrlCacheGetEntryInfo');
// hAppCache : void* optional -> Pointer<Void>
// pcwszUrl : LPCWSTR -> Pointer<Utf16>
// pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UrlCacheGetEntryInfo(
hAppCache: Pointer; // void* optional
pcwszUrl: PWideChar; // LPCWSTR
pCacheEntryInfo: Pointer // URLCACHE_ENTRY_INFO* optional, out
): DWORD; stdcall;
external 'WININET.dll' name 'UrlCacheGetEntryInfo';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UrlCacheGetEntryInfo"
c_UrlCacheGetEntryInfo :: Ptr () -> CWString -> Ptr () -> IO Word32
-- hAppCache : void* optional -> Ptr ()
-- pcwszUrl : LPCWSTR -> CWString
-- pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let urlcachegetentryinfo =
foreign "UrlCacheGetEntryInfo"
((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> returning uint32_t)
(* hAppCache : void* optional -> (ptr void) *)
(* pcwszUrl : LPCWSTR -> (ptr uint16_t) *)
(* pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, 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 ("UrlCacheGetEntryInfo" url-cache-get-entry-info :convention :stdcall) :uint32
(h-app-cache :pointer) ; void* optional
(pcwsz-url (:string :encoding :utf-16le)) ; LPCWSTR
(p-cache-entry-info :pointer)) ; URLCACHE_ENTRY_INFO* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UrlCacheGetEntryInfo = Win32::API::More->new('WININET',
'DWORD UrlCacheGetEntryInfo(LPVOID hAppCache, LPCWSTR pcwszUrl, LPVOID pCacheEntryInfo)');
# my $ret = $UrlCacheGetEntryInfo->Call($hAppCache, $pcwszUrl, $pCacheEntryInfo);
# hAppCache : void* optional -> LPVOID
# pcwszUrl : LPCWSTR -> LPCWSTR
# pCacheEntryInfo : URLCACHE_ENTRY_INFO* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。