ホーム › Networking.WinInet › CreateUrlCacheEntryExW
CreateUrlCacheEntryExW
関数拡張オプション付きでURLキャッシュエントリを作成する。
シグネチャ
// WININET.dll
#include <windows.h>
BOOL CreateUrlCacheEntryExW(
LPCWSTR lpszUrlName,
DWORD dwExpectedFileSize,
LPCWSTR lpszFileExtension, // optional
LPWSTR lpszFileName,
DWORD dwReserved,
BOOL fPreserveIncomingFileName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpszUrlName | LPCWSTR | in |
| dwExpectedFileSize | DWORD | in |
| lpszFileExtension | LPCWSTR | inoptional |
| lpszFileName | LPWSTR | inout |
| dwReserved | DWORD | in |
| fPreserveIncomingFileName | BOOL | in |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll
#include <windows.h>
BOOL CreateUrlCacheEntryExW(
LPCWSTR lpszUrlName,
DWORD dwExpectedFileSize,
LPCWSTR lpszFileExtension, // optional
LPWSTR lpszFileName,
DWORD dwReserved,
BOOL fPreserveIncomingFileName
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", ExactSpelling = true)]
static extern bool CreateUrlCacheEntryExW(
[MarshalAs(UnmanagedType.LPWStr)] string lpszUrlName, // LPCWSTR
uint dwExpectedFileSize, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpszFileExtension, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszFileName, // LPWSTR in/out
uint dwReserved, // DWORD
bool fPreserveIncomingFileName // BOOL
);<DllImport("WININET.dll", ExactSpelling:=True)>
Public Shared Function CreateUrlCacheEntryExW(
<MarshalAs(UnmanagedType.LPWStr)> lpszUrlName As String, ' LPCWSTR
dwExpectedFileSize As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpszFileExtension As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> lpszFileName As System.Text.StringBuilder, ' LPWSTR in/out
dwReserved As UInteger, ' DWORD
fPreserveIncomingFileName As Boolean ' BOOL
) As Boolean
End Function' lpszUrlName : LPCWSTR
' dwExpectedFileSize : DWORD
' lpszFileExtension : LPCWSTR optional
' lpszFileName : LPWSTR in/out
' dwReserved : DWORD
' fPreserveIncomingFileName : BOOL
Declare PtrSafe Function CreateUrlCacheEntryExW Lib "wininet" ( _
ByVal lpszUrlName As LongPtr, _
ByVal dwExpectedFileSize As Long, _
ByVal lpszFileExtension As LongPtr, _
ByVal lpszFileName As LongPtr, _
ByVal dwReserved As Long, _
ByVal fPreserveIncomingFileName As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateUrlCacheEntryExW = ctypes.windll.wininet.CreateUrlCacheEntryExW
CreateUrlCacheEntryExW.restype = wintypes.BOOL
CreateUrlCacheEntryExW.argtypes = [
wintypes.LPCWSTR, # lpszUrlName : LPCWSTR
wintypes.DWORD, # dwExpectedFileSize : DWORD
wintypes.LPCWSTR, # lpszFileExtension : LPCWSTR optional
wintypes.LPWSTR, # lpszFileName : LPWSTR in/out
wintypes.DWORD, # dwReserved : DWORD
wintypes.BOOL, # fPreserveIncomingFileName : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
CreateUrlCacheEntryExW = Fiddle::Function.new(
lib['CreateUrlCacheEntryExW'],
[
Fiddle::TYPE_VOIDP, # lpszUrlName : LPCWSTR
-Fiddle::TYPE_INT, # dwExpectedFileSize : DWORD
Fiddle::TYPE_VOIDP, # lpszFileExtension : LPCWSTR optional
Fiddle::TYPE_VOIDP, # lpszFileName : LPWSTR in/out
-Fiddle::TYPE_INT, # dwReserved : DWORD
Fiddle::TYPE_INT, # fPreserveIncomingFileName : BOOL
],
Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn CreateUrlCacheEntryExW(
lpszUrlName: *const u16, // LPCWSTR
dwExpectedFileSize: u32, // DWORD
lpszFileExtension: *const u16, // LPCWSTR optional
lpszFileName: *mut u16, // LPWSTR in/out
dwReserved: u32, // DWORD
fPreserveIncomingFileName: i32 // BOOL
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll")]
public static extern bool CreateUrlCacheEntryExW([MarshalAs(UnmanagedType.LPWStr)] string lpszUrlName, uint dwExpectedFileSize, [MarshalAs(UnmanagedType.LPWStr)] string lpszFileExtension, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszFileName, uint dwReserved, bool fPreserveIncomingFileName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_CreateUrlCacheEntryExW' -Namespace Win32 -PassThru
# $api::CreateUrlCacheEntryExW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, lpszFileName, dwReserved, fPreserveIncomingFileName)#uselib "WININET.dll"
#func global CreateUrlCacheEntryExW "CreateUrlCacheEntryExW" sptr, sptr, sptr, sptr, sptr, sptr
; CreateUrlCacheEntryExW lpszUrlName, dwExpectedFileSize, lpszFileExtension, varptr(lpszFileName), dwReserved, fPreserveIncomingFileName ; 戻り値は stat
; lpszUrlName : LPCWSTR -> "sptr"
; dwExpectedFileSize : DWORD -> "sptr"
; lpszFileExtension : LPCWSTR optional -> "sptr"
; lpszFileName : LPWSTR in/out -> "sptr"
; dwReserved : DWORD -> "sptr"
; fPreserveIncomingFileName : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global CreateUrlCacheEntryExW "CreateUrlCacheEntryExW" wstr, int, wstr, var, int, int ; res = CreateUrlCacheEntryExW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, lpszFileName, dwReserved, fPreserveIncomingFileName) ; lpszUrlName : LPCWSTR -> "wstr" ; dwExpectedFileSize : DWORD -> "int" ; lpszFileExtension : LPCWSTR optional -> "wstr" ; lpszFileName : LPWSTR in/out -> "var" ; dwReserved : DWORD -> "int" ; fPreserveIncomingFileName : BOOL -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global CreateUrlCacheEntryExW "CreateUrlCacheEntryExW" wstr, int, wstr, sptr, int, int ; res = CreateUrlCacheEntryExW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, varptr(lpszFileName), dwReserved, fPreserveIncomingFileName) ; lpszUrlName : LPCWSTR -> "wstr" ; dwExpectedFileSize : DWORD -> "int" ; lpszFileExtension : LPCWSTR optional -> "wstr" ; lpszFileName : LPWSTR in/out -> "sptr" ; dwReserved : DWORD -> "int" ; fPreserveIncomingFileName : BOOL -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CreateUrlCacheEntryExW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved, BOOL fPreserveIncomingFileName) #uselib "WININET.dll" #cfunc global CreateUrlCacheEntryExW "CreateUrlCacheEntryExW" wstr, int, wstr, var, int, int ; res = CreateUrlCacheEntryExW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, lpszFileName, dwReserved, fPreserveIncomingFileName) ; lpszUrlName : LPCWSTR -> "wstr" ; dwExpectedFileSize : DWORD -> "int" ; lpszFileExtension : LPCWSTR optional -> "wstr" ; lpszFileName : LPWSTR in/out -> "var" ; dwReserved : DWORD -> "int" ; fPreserveIncomingFileName : BOOL -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CreateUrlCacheEntryExW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved, BOOL fPreserveIncomingFileName) #uselib "WININET.dll" #cfunc global CreateUrlCacheEntryExW "CreateUrlCacheEntryExW" wstr, int, wstr, intptr, int, int ; res = CreateUrlCacheEntryExW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, varptr(lpszFileName), dwReserved, fPreserveIncomingFileName) ; lpszUrlName : LPCWSTR -> "wstr" ; dwExpectedFileSize : DWORD -> "int" ; lpszFileExtension : LPCWSTR optional -> "wstr" ; lpszFileName : LPWSTR in/out -> "intptr" ; dwReserved : DWORD -> "int" ; fPreserveIncomingFileName : BOOL -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procCreateUrlCacheEntryExW = wininet.NewProc("CreateUrlCacheEntryExW")
)
// lpszUrlName (LPCWSTR), dwExpectedFileSize (DWORD), lpszFileExtension (LPCWSTR optional), lpszFileName (LPWSTR in/out), dwReserved (DWORD), fPreserveIncomingFileName (BOOL)
r1, _, err := procCreateUrlCacheEntryExW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszUrlName))),
uintptr(dwExpectedFileSize),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszFileExtension))),
uintptr(lpszFileName),
uintptr(dwReserved),
uintptr(fPreserveIncomingFileName),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CreateUrlCacheEntryExW(
lpszUrlName: PWideChar; // LPCWSTR
dwExpectedFileSize: DWORD; // DWORD
lpszFileExtension: PWideChar; // LPCWSTR optional
lpszFileName: PWideChar; // LPWSTR in/out
dwReserved: DWORD; // DWORD
fPreserveIncomingFileName: BOOL // BOOL
): BOOL; stdcall;
external 'WININET.dll' name 'CreateUrlCacheEntryExW';result := DllCall("WININET\CreateUrlCacheEntryExW"
, "WStr", lpszUrlName ; LPCWSTR
, "UInt", dwExpectedFileSize ; DWORD
, "WStr", lpszFileExtension ; LPCWSTR optional
, "Ptr", lpszFileName ; LPWSTR in/out
, "UInt", dwReserved ; DWORD
, "Int", fPreserveIncomingFileName ; BOOL
, "Int") ; return: BOOL●CreateUrlCacheEntryExW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, lpszFileName, dwReserved, fPreserveIncomingFileName) = DLL("WININET.dll", "bool CreateUrlCacheEntryExW(char*, dword, char*, char*, dword, bool)")
# 呼び出し: CreateUrlCacheEntryExW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, lpszFileName, dwReserved, fPreserveIncomingFileName)
# lpszUrlName : LPCWSTR -> "char*"
# dwExpectedFileSize : DWORD -> "dword"
# lpszFileExtension : LPCWSTR optional -> "char*"
# lpszFileName : LPWSTR in/out -> "char*"
# dwReserved : DWORD -> "dword"
# fPreserveIncomingFileName : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。