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

FindFirstUrlCacheEntryW

関数
URLキャッシュエントリの列挙を開始し最初の項目を取得する(Unicode版)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

HANDLE FindFirstUrlCacheEntryW(
    LPCWSTR lpszUrlSearchPattern,   // optional
    INTERNET_CACHE_ENTRY_INFOW* lpFirstCacheEntryInfo,   // optional
    DWORD* lpcbCacheEntryInfo
);

パラメーター

名前方向
lpszUrlSearchPatternLPCWSTRinoptional
lpFirstCacheEntryInfoINTERNET_CACHE_ENTRY_INFOW*inoutoptional
lpcbCacheEntryInfoDWORD*inout

戻り値の型: HANDLE

各言語での呼び出し定義

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

HANDLE FindFirstUrlCacheEntryW(
    LPCWSTR lpszUrlSearchPattern,   // optional
    INTERNET_CACHE_ENTRY_INFOW* lpFirstCacheEntryInfo,   // optional
    DWORD* lpcbCacheEntryInfo
);
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr FindFirstUrlCacheEntryW(
    [MarshalAs(UnmanagedType.LPWStr)] string lpszUrlSearchPattern,   // LPCWSTR optional
    IntPtr lpFirstCacheEntryInfo,   // INTERNET_CACHE_ENTRY_INFOW* optional, in/out
    ref uint lpcbCacheEntryInfo   // DWORD* in/out
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindFirstUrlCacheEntryW(
    <MarshalAs(UnmanagedType.LPWStr)> lpszUrlSearchPattern As String,   ' LPCWSTR optional
    lpFirstCacheEntryInfo As IntPtr,   ' INTERNET_CACHE_ENTRY_INFOW* optional, in/out
    ByRef lpcbCacheEntryInfo As UInteger   ' DWORD* in/out
) As IntPtr
End Function
' lpszUrlSearchPattern : LPCWSTR optional
' lpFirstCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out
' lpcbCacheEntryInfo : DWORD* in/out
Declare PtrSafe Function FindFirstUrlCacheEntryW Lib "wininet" ( _
    ByVal lpszUrlSearchPattern As LongPtr, _
    ByVal lpFirstCacheEntryInfo As LongPtr, _
    ByRef lpcbCacheEntryInfo As Long) As LongPtr
' 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

FindFirstUrlCacheEntryW = ctypes.windll.wininet.FindFirstUrlCacheEntryW
FindFirstUrlCacheEntryW.restype = ctypes.c_void_p
FindFirstUrlCacheEntryW.argtypes = [
    wintypes.LPCWSTR,  # lpszUrlSearchPattern : LPCWSTR optional
    ctypes.c_void_p,  # lpFirstCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out
    ctypes.POINTER(wintypes.DWORD),  # lpcbCacheEntryInfo : DWORD* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
FindFirstUrlCacheEntryW = Fiddle::Function.new(
  lib['FindFirstUrlCacheEntryW'],
  [
    Fiddle::TYPE_VOIDP,  # lpszUrlSearchPattern : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # lpFirstCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out
    Fiddle::TYPE_VOIDP,  # lpcbCacheEntryInfo : DWORD* in/out
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn FindFirstUrlCacheEntryW(
        lpszUrlSearchPattern: *const u16,  // LPCWSTR optional
        lpFirstCacheEntryInfo: *mut INTERNET_CACHE_ENTRY_INFOW,  // INTERNET_CACHE_ENTRY_INFOW* optional, in/out
        lpcbCacheEntryInfo: *mut u32  // DWORD* in/out
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr FindFirstUrlCacheEntryW([MarshalAs(UnmanagedType.LPWStr)] string lpszUrlSearchPattern, IntPtr lpFirstCacheEntryInfo, ref uint lpcbCacheEntryInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_FindFirstUrlCacheEntryW' -Namespace Win32 -PassThru
# $api::FindFirstUrlCacheEntryW(lpszUrlSearchPattern, lpFirstCacheEntryInfo, lpcbCacheEntryInfo)
#uselib "WININET.dll"
#func global FindFirstUrlCacheEntryW "FindFirstUrlCacheEntryW" wptr, wptr, wptr
; FindFirstUrlCacheEntryW lpszUrlSearchPattern, varptr(lpFirstCacheEntryInfo), varptr(lpcbCacheEntryInfo)   ; 戻り値は stat
; lpszUrlSearchPattern : LPCWSTR optional -> "wptr"
; lpFirstCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "wptr"
; lpcbCacheEntryInfo : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global FindFirstUrlCacheEntryW "FindFirstUrlCacheEntryW" wstr, var, var
; res = FindFirstUrlCacheEntryW(lpszUrlSearchPattern, lpFirstCacheEntryInfo, lpcbCacheEntryInfo)
; lpszUrlSearchPattern : LPCWSTR optional -> "wstr"
; lpFirstCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "var"
; lpcbCacheEntryInfo : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HANDLE FindFirstUrlCacheEntryW(LPCWSTR lpszUrlSearchPattern, INTERNET_CACHE_ENTRY_INFOW* lpFirstCacheEntryInfo, DWORD* lpcbCacheEntryInfo)
#uselib "WININET.dll"
#cfunc global FindFirstUrlCacheEntryW "FindFirstUrlCacheEntryW" wstr, var, var
; res = FindFirstUrlCacheEntryW(lpszUrlSearchPattern, lpFirstCacheEntryInfo, lpcbCacheEntryInfo)
; lpszUrlSearchPattern : LPCWSTR optional -> "wstr"
; lpFirstCacheEntryInfo : INTERNET_CACHE_ENTRY_INFOW* optional, in/out -> "var"
; lpcbCacheEntryInfo : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procFindFirstUrlCacheEntryW = wininet.NewProc("FindFirstUrlCacheEntryW")
)

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