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