ホーム › 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 |
| dwContainerType | DWORD | in |
| dwOptions | DWORD | in |
| pvBuffer | void* | optional |
| cbBuffer | DWORD* | optional |
戻り値の型: BOOL
各言語での呼び出し定義
// 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 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 版の利用を推奨。