ホーム › Networking.WinInet › CreateUrlCacheContainerW
CreateUrlCacheContainerW
関数URLキャッシュコンテナを作成する(Unicode版)。
シグネチャ
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL CreateUrlCacheContainerW(
LPCWSTR Name,
LPCWSTR lpCachePrefix,
LPCWSTR lpszCachePath, // optional
DWORD KBCacheLimit,
DWORD dwContainerType,
DWORD dwOptions,
void* pvBuffer, // optional
DWORD* cbBuffer // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Name | LPCWSTR | in | キャッシュに付ける名前。 |
| lpCachePrefix | LPCWSTR | in | キャッシュの基準とするキャッシュプレフィックス。 |
| lpszCachePath | LPCWSTR | inoptional | キャッシュを作成するキャッシュプレフィックス。 |
| KBCacheLimit | DWORD | in | キャッシュのサイズ上限(キロバイト単位の整数値)。既定のサイズの場合は 0。 |
| dwContainerType | DWORD | in | キャッシュの基準とするコンテナータイプ。 |
| dwOptions | DWORD | in | このパラメーターは予約されており、0 でなければなりません。 |
| pvBuffer | void* | optional | このパラメーターは予約されており、NULL でなければなりません。 |
| cbBuffer | DWORD* | optional | このパラメーターは予約されており、NULL でなければなりません。 |
戻り値の型: BOOL
公式ドキュメント
指定されたキャッシュパス内に、指定された名前、キャッシュプレフィックス、コンテナータイプに基づいてキャッシュエントリを保持するキャッシュコンテナーを作成します。(Unicode)
戻り値
成功した場合は TRUE を、それ以外の場合は FALSE を返します。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
メモ
winineti.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして CreateUrlCacheContainer を定義しています。エンコーディング非依存のエイリアスを、エンコーディング非依存でないコードと混在させて使用すると、コンパイルエラーや実行時エラーを引き起こす不一致が生じる可能性があります。詳細については、関数プロトタイプの規則を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL CreateUrlCacheContainerW(
LPCWSTR Name,
LPCWSTR lpCachePrefix,
LPCWSTR lpszCachePath, // optional
DWORD KBCacheLimit,
DWORD dwContainerType,
DWORD dwOptions,
void* pvBuffer, // optional
DWORD* cbBuffer // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool CreateUrlCacheContainerW(
[MarshalAs(UnmanagedType.LPWStr)] string Name, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpCachePrefix, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszCachePath, // LPCWSTR optional
uint KBCacheLimit, // DWORD
uint dwContainerType, // DWORD
uint dwOptions, // DWORD
IntPtr pvBuffer, // void* optional
IntPtr cbBuffer // DWORD* optional
);<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateUrlCacheContainerW(
<MarshalAs(UnmanagedType.LPWStr)> Name As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpCachePrefix As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszCachePath As String, ' LPCWSTR optional
KBCacheLimit As UInteger, ' DWORD
dwContainerType As UInteger, ' DWORD
dwOptions As UInteger, ' DWORD
pvBuffer As IntPtr, ' void* optional
cbBuffer As IntPtr ' DWORD* optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' Name : LPCWSTR
' lpCachePrefix : LPCWSTR
' lpszCachePath : LPCWSTR optional
' KBCacheLimit : DWORD
' dwContainerType : DWORD
' dwOptions : DWORD
' pvBuffer : void* optional
' cbBuffer : DWORD* optional
Declare PtrSafe Function CreateUrlCacheContainerW Lib "wininet" ( _
ByVal Name As LongPtr, _
ByVal lpCachePrefix As LongPtr, _
ByVal lpszCachePath As LongPtr, _
ByVal KBCacheLimit As Long, _
ByVal dwContainerType As Long, _
ByVal dwOptions As Long, _
ByVal pvBuffer As LongPtr, _
ByVal cbBuffer As LongPtr) 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
CreateUrlCacheContainerW = ctypes.windll.wininet.CreateUrlCacheContainerW
CreateUrlCacheContainerW.restype = wintypes.BOOL
CreateUrlCacheContainerW.argtypes = [
wintypes.LPCWSTR, # Name : LPCWSTR
wintypes.LPCWSTR, # lpCachePrefix : LPCWSTR
wintypes.LPCWSTR, # lpszCachePath : LPCWSTR optional
wintypes.DWORD, # KBCacheLimit : DWORD
wintypes.DWORD, # dwContainerType : DWORD
wintypes.DWORD, # dwOptions : DWORD
ctypes.POINTER(None), # pvBuffer : void* optional
ctypes.POINTER(wintypes.DWORD), # cbBuffer : DWORD* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
CreateUrlCacheContainerW = Fiddle::Function.new(
lib['CreateUrlCacheContainerW'],
[
Fiddle::TYPE_VOIDP, # Name : LPCWSTR
Fiddle::TYPE_VOIDP, # lpCachePrefix : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszCachePath : LPCWSTR optional
-Fiddle::TYPE_INT, # KBCacheLimit : DWORD
-Fiddle::TYPE_INT, # dwContainerType : DWORD
-Fiddle::TYPE_INT, # dwOptions : DWORD
Fiddle::TYPE_VOIDP, # pvBuffer : void* optional
Fiddle::TYPE_VOIDP, # cbBuffer : DWORD* optional
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wininet")]
extern "system" {
fn CreateUrlCacheContainerW(
Name: *const u16, // LPCWSTR
lpCachePrefix: *const u16, // LPCWSTR
lpszCachePath: *const u16, // LPCWSTR optional
KBCacheLimit: u32, // DWORD
dwContainerType: u32, // DWORD
dwOptions: u32, // DWORD
pvBuffer: *mut (), // void* optional
cbBuffer: *mut 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 CreateUrlCacheContainerW([MarshalAs(UnmanagedType.LPWStr)] string Name, [MarshalAs(UnmanagedType.LPWStr)] string lpCachePrefix, [MarshalAs(UnmanagedType.LPWStr)] string lpszCachePath, uint KBCacheLimit, uint dwContainerType, uint dwOptions, IntPtr pvBuffer, IntPtr cbBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_CreateUrlCacheContainerW' -Namespace Win32 -PassThru
# $api::CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer)#uselib "WININET.dll"
#func global CreateUrlCacheContainerW "CreateUrlCacheContainerW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; CreateUrlCacheContainerW Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, varptr(cbBuffer) ; 戻り値は stat
; Name : LPCWSTR -> "wptr"
; lpCachePrefix : LPCWSTR -> "wptr"
; lpszCachePath : LPCWSTR optional -> "wptr"
; KBCacheLimit : DWORD -> "wptr"
; dwContainerType : DWORD -> "wptr"
; dwOptions : DWORD -> "wptr"
; pvBuffer : void* optional -> "wptr"
; cbBuffer : DWORD* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global CreateUrlCacheContainerW "CreateUrlCacheContainerW" wstr, wstr, wstr, int, int, int, sptr, var ; res = CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer) ; Name : LPCWSTR -> "wstr" ; lpCachePrefix : LPCWSTR -> "wstr" ; lpszCachePath : LPCWSTR optional -> "wstr" ; KBCacheLimit : DWORD -> "int" ; dwContainerType : DWORD -> "int" ; dwOptions : DWORD -> "int" ; pvBuffer : void* optional -> "sptr" ; cbBuffer : DWORD* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global CreateUrlCacheContainerW "CreateUrlCacheContainerW" wstr, wstr, wstr, int, int, int, sptr, sptr ; res = CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, varptr(cbBuffer)) ; Name : LPCWSTR -> "wstr" ; lpCachePrefix : LPCWSTR -> "wstr" ; lpszCachePath : LPCWSTR optional -> "wstr" ; KBCacheLimit : DWORD -> "int" ; dwContainerType : DWORD -> "int" ; dwOptions : DWORD -> "int" ; pvBuffer : void* optional -> "sptr" ; cbBuffer : DWORD* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CreateUrlCacheContainerW(LPCWSTR Name, LPCWSTR lpCachePrefix, LPCWSTR lpszCachePath, DWORD KBCacheLimit, DWORD dwContainerType, DWORD dwOptions, void* pvBuffer, DWORD* cbBuffer) #uselib "WININET.dll" #cfunc global CreateUrlCacheContainerW "CreateUrlCacheContainerW" wstr, wstr, wstr, int, int, int, intptr, var ; res = CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer) ; Name : LPCWSTR -> "wstr" ; lpCachePrefix : LPCWSTR -> "wstr" ; lpszCachePath : LPCWSTR optional -> "wstr" ; KBCacheLimit : DWORD -> "int" ; dwContainerType : DWORD -> "int" ; dwOptions : DWORD -> "int" ; pvBuffer : void* optional -> "intptr" ; cbBuffer : DWORD* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CreateUrlCacheContainerW(LPCWSTR Name, LPCWSTR lpCachePrefix, LPCWSTR lpszCachePath, DWORD KBCacheLimit, DWORD dwContainerType, DWORD dwOptions, void* pvBuffer, DWORD* cbBuffer) #uselib "WININET.dll" #cfunc global CreateUrlCacheContainerW "CreateUrlCacheContainerW" wstr, wstr, wstr, int, int, int, intptr, intptr ; res = CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, varptr(cbBuffer)) ; Name : LPCWSTR -> "wstr" ; lpCachePrefix : LPCWSTR -> "wstr" ; lpszCachePath : LPCWSTR optional -> "wstr" ; KBCacheLimit : DWORD -> "int" ; dwContainerType : DWORD -> "int" ; dwOptions : DWORD -> "int" ; pvBuffer : void* optional -> "intptr" ; cbBuffer : DWORD* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procCreateUrlCacheContainerW = wininet.NewProc("CreateUrlCacheContainerW")
)
// Name (LPCWSTR), lpCachePrefix (LPCWSTR), lpszCachePath (LPCWSTR optional), KBCacheLimit (DWORD), dwContainerType (DWORD), dwOptions (DWORD), pvBuffer (void* optional), cbBuffer (DWORD* optional)
r1, _, err := procCreateUrlCacheContainerW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Name))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpCachePrefix))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszCachePath))),
uintptr(KBCacheLimit),
uintptr(dwContainerType),
uintptr(dwOptions),
uintptr(pvBuffer),
uintptr(cbBuffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CreateUrlCacheContainerW(
Name: PWideChar; // LPCWSTR
lpCachePrefix: PWideChar; // LPCWSTR
lpszCachePath: PWideChar; // LPCWSTR optional
KBCacheLimit: DWORD; // DWORD
dwContainerType: DWORD; // DWORD
dwOptions: DWORD; // DWORD
pvBuffer: Pointer; // void* optional
cbBuffer: Pointer // DWORD* optional
): BOOL; stdcall;
external 'WININET.dll' name 'CreateUrlCacheContainerW';result := DllCall("WININET\CreateUrlCacheContainerW"
, "WStr", Name ; LPCWSTR
, "WStr", lpCachePrefix ; LPCWSTR
, "WStr", lpszCachePath ; LPCWSTR optional
, "UInt", KBCacheLimit ; DWORD
, "UInt", dwContainerType ; DWORD
, "UInt", dwOptions ; DWORD
, "Ptr", pvBuffer ; void* optional
, "Ptr", cbBuffer ; DWORD* optional
, "Int") ; return: BOOL●CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer) = DLL("WININET.dll", "bool CreateUrlCacheContainerW(char*, char*, char*, dword, dword, dword, void*, void*)")
# 呼び出し: CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer)
# Name : LPCWSTR -> "char*"
# lpCachePrefix : LPCWSTR -> "char*"
# lpszCachePath : LPCWSTR optional -> "char*"
# KBCacheLimit : DWORD -> "dword"
# dwContainerType : DWORD -> "dword"
# dwOptions : DWORD -> "dword"
# pvBuffer : void* optional -> "void*"
# cbBuffer : DWORD* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "wininet" fn CreateUrlCacheContainerW(
Name: [*c]const u16, // LPCWSTR
lpCachePrefix: [*c]const u16, // LPCWSTR
lpszCachePath: [*c]const u16, // LPCWSTR optional
KBCacheLimit: u32, // DWORD
dwContainerType: u32, // DWORD
dwOptions: u32, // DWORD
pvBuffer: ?*anyopaque, // void* optional
cbBuffer: [*c]u32 // DWORD* optional
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc CreateUrlCacheContainerW(
Name: WideCString, # LPCWSTR
lpCachePrefix: WideCString, # LPCWSTR
lpszCachePath: WideCString, # LPCWSTR optional
KBCacheLimit: uint32, # DWORD
dwContainerType: uint32, # DWORD
dwOptions: uint32, # DWORD
pvBuffer: pointer, # void* optional
cbBuffer: ptr uint32 # DWORD* optional
): int32 {.importc: "CreateUrlCacheContainerW", stdcall, dynlib: "WININET.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "wininet");
extern(Windows)
int CreateUrlCacheContainerW(
const(wchar)* Name, // LPCWSTR
const(wchar)* lpCachePrefix, // LPCWSTR
const(wchar)* lpszCachePath, // LPCWSTR optional
uint KBCacheLimit, // DWORD
uint dwContainerType, // DWORD
uint dwOptions, // DWORD
void* pvBuffer, // void* optional
uint* cbBuffer // DWORD* optional
);ccall((:CreateUrlCacheContainerW, "WININET.dll"), stdcall, Int32,
(Cwstring, Cwstring, Cwstring, UInt32, UInt32, UInt32, Ptr{Cvoid}, Ptr{UInt32}),
Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer)
# Name : LPCWSTR -> Cwstring
# lpCachePrefix : LPCWSTR -> Cwstring
# lpszCachePath : LPCWSTR optional -> Cwstring
# KBCacheLimit : DWORD -> UInt32
# dwContainerType : DWORD -> UInt32
# dwOptions : DWORD -> UInt32
# pvBuffer : void* optional -> Ptr{Cvoid}
# cbBuffer : DWORD* optional -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t CreateUrlCacheContainerW(
const uint16_t* Name,
const uint16_t* lpCachePrefix,
const uint16_t* lpszCachePath,
uint32_t KBCacheLimit,
uint32_t dwContainerType,
uint32_t dwOptions,
void* pvBuffer,
uint32_t* cbBuffer);
]]
local wininet = ffi.load("wininet")
-- wininet.CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer)
-- Name : LPCWSTR
-- lpCachePrefix : LPCWSTR
-- lpszCachePath : LPCWSTR optional
-- KBCacheLimit : DWORD
-- dwContainerType : DWORD
-- dwOptions : DWORD
-- pvBuffer : void* optional
-- cbBuffer : 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 CreateUrlCacheContainerW = lib.func('__stdcall', 'CreateUrlCacheContainerW', 'int32_t', ['str16', 'str16', 'str16', 'uint32_t', 'uint32_t', 'uint32_t', 'void *', 'uint32_t *']);
// CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer)
// Name : LPCWSTR -> 'str16'
// lpCachePrefix : LPCWSTR -> 'str16'
// lpszCachePath : LPCWSTR optional -> 'str16'
// KBCacheLimit : DWORD -> 'uint32_t'
// dwContainerType : DWORD -> 'uint32_t'
// dwOptions : DWORD -> 'uint32_t'
// pvBuffer : void* optional -> 'void *'
// cbBuffer : DWORD* optional -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
CreateUrlCacheContainerW: { parameters: ["buffer", "buffer", "buffer", "u32", "u32", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer)
// Name : LPCWSTR -> "buffer"
// lpCachePrefix : LPCWSTR -> "buffer"
// lpszCachePath : LPCWSTR optional -> "buffer"
// KBCacheLimit : DWORD -> "u32"
// dwContainerType : DWORD -> "u32"
// dwOptions : DWORD -> "u32"
// pvBuffer : void* optional -> "pointer"
// cbBuffer : DWORD* optional -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CreateUrlCacheContainerW(
const uint16_t* Name,
const uint16_t* lpCachePrefix,
const uint16_t* lpszCachePath,
uint32_t KBCacheLimit,
uint32_t dwContainerType,
uint32_t dwOptions,
void* pvBuffer,
uint32_t* cbBuffer);
C, "WININET.dll");
// $ffi->CreateUrlCacheContainerW(Name, lpCachePrefix, lpszCachePath, KBCacheLimit, dwContainerType, dwOptions, pvBuffer, cbBuffer);
// Name : LPCWSTR
// lpCachePrefix : LPCWSTR
// lpszCachePath : LPCWSTR optional
// KBCacheLimit : DWORD
// dwContainerType : DWORD
// dwOptions : DWORD
// pvBuffer : void* optional
// cbBuffer : 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 CreateUrlCacheContainerW(
WString Name, // LPCWSTR
WString lpCachePrefix, // LPCWSTR
WString lpszCachePath, // LPCWSTR optional
int KBCacheLimit, // DWORD
int dwContainerType, // DWORD
int dwOptions, // DWORD
Pointer pvBuffer, // void* optional
IntByReference cbBuffer // DWORD* optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("wininet")]
lib LibWININET
fun CreateUrlCacheContainerW = CreateUrlCacheContainerW(
Name : UInt16*, # LPCWSTR
lpCachePrefix : UInt16*, # LPCWSTR
lpszCachePath : UInt16*, # LPCWSTR optional
KBCacheLimit : UInt32, # DWORD
dwContainerType : UInt32, # DWORD
dwOptions : UInt32, # DWORD
pvBuffer : Void*, # void* optional
cbBuffer : 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 CreateUrlCacheContainerWNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32, Uint32, Uint32, Pointer<Void>, Pointer<Uint32>);
typedef CreateUrlCacheContainerWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int, int, int, Pointer<Void>, Pointer<Uint32>);
final CreateUrlCacheContainerW = DynamicLibrary.open('WININET.dll')
.lookupFunction<CreateUrlCacheContainerWNative, CreateUrlCacheContainerWDart>('CreateUrlCacheContainerW');
// Name : LPCWSTR -> Pointer<Utf16>
// lpCachePrefix : LPCWSTR -> Pointer<Utf16>
// lpszCachePath : LPCWSTR optional -> Pointer<Utf16>
// KBCacheLimit : DWORD -> Uint32
// dwContainerType : DWORD -> Uint32
// dwOptions : DWORD -> Uint32
// pvBuffer : void* optional -> Pointer<Void>
// cbBuffer : DWORD* optional -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CreateUrlCacheContainerW(
Name: PWideChar; // LPCWSTR
lpCachePrefix: PWideChar; // LPCWSTR
lpszCachePath: PWideChar; // LPCWSTR optional
KBCacheLimit: DWORD; // DWORD
dwContainerType: DWORD; // DWORD
dwOptions: DWORD; // DWORD
pvBuffer: Pointer; // void* optional
cbBuffer: Pointer // DWORD* optional
): BOOL; stdcall;
external 'WININET.dll' name 'CreateUrlCacheContainerW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CreateUrlCacheContainerW"
c_CreateUrlCacheContainerW :: CWString -> CWString -> CWString -> Word32 -> Word32 -> Word32 -> Ptr () -> Ptr Word32 -> IO CInt
-- Name : LPCWSTR -> CWString
-- lpCachePrefix : LPCWSTR -> CWString
-- lpszCachePath : LPCWSTR optional -> CWString
-- KBCacheLimit : DWORD -> Word32
-- dwContainerType : DWORD -> Word32
-- dwOptions : DWORD -> Word32
-- pvBuffer : void* optional -> Ptr ()
-- cbBuffer : DWORD* optional -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let createurlcachecontainerw =
foreign "CreateUrlCacheContainerW"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* Name : LPCWSTR -> (ptr uint16_t) *)
(* lpCachePrefix : LPCWSTR -> (ptr uint16_t) *)
(* lpszCachePath : LPCWSTR optional -> (ptr uint16_t) *)
(* KBCacheLimit : DWORD -> uint32_t *)
(* dwContainerType : DWORD -> uint32_t *)
(* dwOptions : DWORD -> uint32_t *)
(* pvBuffer : void* optional -> (ptr void) *)
(* cbBuffer : DWORD* optional -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("CreateUrlCacheContainerW" create-url-cache-container-w :convention :stdcall) :int32
(name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-cache-prefix (:string :encoding :utf-16le)) ; LPCWSTR
(lpsz-cache-path (:string :encoding :utf-16le)) ; LPCWSTR optional
(kbcache-limit :uint32) ; DWORD
(dw-container-type :uint32) ; DWORD
(dw-options :uint32) ; DWORD
(pv-buffer :pointer) ; void* optional
(cb-buffer :pointer)) ; DWORD* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CreateUrlCacheContainerW = Win32::API::More->new('WININET',
'BOOL CreateUrlCacheContainerW(LPCWSTR Name, LPCWSTR lpCachePrefix, LPCWSTR lpszCachePath, DWORD KBCacheLimit, DWORD dwContainerType, DWORD dwOptions, LPVOID pvBuffer, LPVOID cbBuffer)');
# my $ret = $CreateUrlCacheContainerW->Call($Name, $lpCachePrefix, $lpszCachePath, $KBCacheLimit, $dwContainerType, $dwOptions, $pvBuffer, $cbBuffer);
# Name : LPCWSTR -> LPCWSTR
# lpCachePrefix : LPCWSTR -> LPCWSTR
# lpszCachePath : LPCWSTR optional -> LPCWSTR
# KBCacheLimit : DWORD -> DWORD
# dwContainerType : DWORD -> DWORD
# dwOptions : DWORD -> DWORD
# pvBuffer : void* optional -> LPVOID
# cbBuffer : DWORD* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f CreateUrlCacheContainerA (ANSI版) — URLキャッシュコンテナを作成する。
公式の関連項目
- f CommitUrlCacheEntryW — 作成したキャッシュファイルをURLキャッシュに登録する(Unicode版)。