ホーム › 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 | キャッシュに取り込む元ファイルのパスを示すUnicode文字列。 |
| pwszUrl | LPCWSTR | in | ファイルに対応付けるURLを示すUnicode文字列。 |
| pbResponseHeaders | BYTE* | in | 対応するHTTPレスポンスヘッダーを格納したバイトバッファへのポインタ。 |
| dwResponseHeadersSize | DWORD | in | pbResponseHeadersのサイズ(バイト)。 |
戻り値の型: 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)。const std = @import("std");
extern "wininet" fn AppCacheCreateAndCommitFile(
hAppCache: ?*anyopaque, // void*
pwszSourceFilePath: [*c]const u16, // LPCWSTR
pwszUrl: [*c]const u16, // LPCWSTR
pbResponseHeaders: [*c]u8, // BYTE*
dwResponseHeadersSize: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc AppCacheCreateAndCommitFile(
hAppCache: pointer, # void*
pwszSourceFilePath: WideCString, # LPCWSTR
pwszUrl: WideCString, # LPCWSTR
pbResponseHeaders: ptr uint8, # BYTE*
dwResponseHeadersSize: uint32 # DWORD
): uint32 {.importc: "AppCacheCreateAndCommitFile", stdcall, dynlib: "WININET.dll".}pragma(lib, "wininet");
extern(Windows)
uint AppCacheCreateAndCommitFile(
void* hAppCache, // void*
const(wchar)* pwszSourceFilePath, // LPCWSTR
const(wchar)* pwszUrl, // LPCWSTR
ubyte* pbResponseHeaders, // BYTE*
uint dwResponseHeadersSize // DWORD
);ccall((:AppCacheCreateAndCommitFile, "WININET.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cwstring, Cwstring, Ptr{UInt8}, UInt32),
hAppCache, pwszSourceFilePath, pwszUrl, pbResponseHeaders, dwResponseHeadersSize)
# hAppCache : void* -> Ptr{Cvoid}
# pwszSourceFilePath : LPCWSTR -> Cwstring
# pwszUrl : LPCWSTR -> Cwstring
# pbResponseHeaders : BYTE* -> Ptr{UInt8}
# dwResponseHeadersSize : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t AppCacheCreateAndCommitFile(
void* hAppCache,
const uint16_t* pwszSourceFilePath,
const uint16_t* pwszUrl,
uint8_t* pbResponseHeaders,
uint32_t dwResponseHeadersSize);
]]
local wininet = ffi.load("wininet")
-- wininet.AppCacheCreateAndCommitFile(hAppCache, pwszSourceFilePath, pwszUrl, pbResponseHeaders, dwResponseHeadersSize)
-- hAppCache : void*
-- pwszSourceFilePath : LPCWSTR
-- pwszUrl : LPCWSTR
-- pbResponseHeaders : BYTE*
-- dwResponseHeadersSize : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const AppCacheCreateAndCommitFile = lib.func('__stdcall', 'AppCacheCreateAndCommitFile', 'uint32_t', ['void *', 'str16', 'str16', 'uint8_t *', 'uint32_t']);
// AppCacheCreateAndCommitFile(hAppCache, pwszSourceFilePath, pwszUrl, pbResponseHeaders, dwResponseHeadersSize)
// hAppCache : void* -> 'void *'
// pwszSourceFilePath : LPCWSTR -> 'str16'
// pwszUrl : LPCWSTR -> 'str16'
// pbResponseHeaders : BYTE* -> 'uint8_t *'
// dwResponseHeadersSize : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
AppCacheCreateAndCommitFile: { parameters: ["pointer", "buffer", "buffer", "pointer", "u32"], result: "u32" },
});
// lib.symbols.AppCacheCreateAndCommitFile(hAppCache, pwszSourceFilePath, pwszUrl, pbResponseHeaders, dwResponseHeadersSize)
// hAppCache : void* -> "pointer"
// pwszSourceFilePath : LPCWSTR -> "buffer"
// pwszUrl : LPCWSTR -> "buffer"
// pbResponseHeaders : BYTE* -> "pointer"
// dwResponseHeadersSize : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t AppCacheCreateAndCommitFile(
void* hAppCache,
const uint16_t* pwszSourceFilePath,
const uint16_t* pwszUrl,
uint8_t* pbResponseHeaders,
uint32_t dwResponseHeadersSize);
C, "WININET.dll");
// $ffi->AppCacheCreateAndCommitFile(hAppCache, pwszSourceFilePath, pwszUrl, pbResponseHeaders, dwResponseHeadersSize);
// hAppCache : void*
// pwszSourceFilePath : LPCWSTR
// pwszUrl : LPCWSTR
// pbResponseHeaders : BYTE*
// dwResponseHeadersSize : DWORD
// 構造体/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);
int AppCacheCreateAndCommitFile(
Pointer hAppCache, // void*
WString pwszSourceFilePath, // LPCWSTR
WString pwszUrl, // LPCWSTR
byte[] pbResponseHeaders, // BYTE*
int dwResponseHeadersSize // DWORD
);
}@[Link("wininet")]
lib LibWININET
fun AppCacheCreateAndCommitFile = AppCacheCreateAndCommitFile(
hAppCache : Void*, # void*
pwszSourceFilePath : UInt16*, # LPCWSTR
pwszUrl : UInt16*, # LPCWSTR
pbResponseHeaders : UInt8*, # BYTE*
dwResponseHeadersSize : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef AppCacheCreateAndCommitFileNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint8>, Uint32);
typedef AppCacheCreateAndCommitFileDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint8>, int);
final AppCacheCreateAndCommitFile = DynamicLibrary.open('WININET.dll')
.lookupFunction<AppCacheCreateAndCommitFileNative, AppCacheCreateAndCommitFileDart>('AppCacheCreateAndCommitFile');
// hAppCache : void* -> Pointer<Void>
// pwszSourceFilePath : LPCWSTR -> Pointer<Utf16>
// pwszUrl : LPCWSTR -> Pointer<Utf16>
// pbResponseHeaders : BYTE* -> Pointer<Uint8>
// dwResponseHeadersSize : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function AppCacheCreateAndCommitFile(
hAppCache: Pointer; // void*
pwszSourceFilePath: PWideChar; // LPCWSTR
pwszUrl: PWideChar; // LPCWSTR
pbResponseHeaders: Pointer; // BYTE*
dwResponseHeadersSize: DWORD // DWORD
): DWORD; stdcall;
external 'WININET.dll' name 'AppCacheCreateAndCommitFile';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "AppCacheCreateAndCommitFile"
c_AppCacheCreateAndCommitFile :: Ptr () -> CWString -> CWString -> Ptr Word8 -> Word32 -> IO Word32
-- hAppCache : void* -> Ptr ()
-- pwszSourceFilePath : LPCWSTR -> CWString
-- pwszUrl : LPCWSTR -> CWString
-- pbResponseHeaders : BYTE* -> Ptr Word8
-- dwResponseHeadersSize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let appcachecreateandcommitfile =
foreign "AppCacheCreateAndCommitFile"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint8_t) @-> uint32_t @-> returning uint32_t)
(* hAppCache : void* -> (ptr void) *)
(* pwszSourceFilePath : LPCWSTR -> (ptr uint16_t) *)
(* pwszUrl : LPCWSTR -> (ptr uint16_t) *)
(* pbResponseHeaders : BYTE* -> (ptr uint8_t) *)
(* dwResponseHeadersSize : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("AppCacheCreateAndCommitFile" app-cache-create-and-commit-file :convention :stdcall) :uint32
(h-app-cache :pointer) ; void*
(pwsz-source-file-path (:string :encoding :utf-16le)) ; LPCWSTR
(pwsz-url (:string :encoding :utf-16le)) ; LPCWSTR
(pb-response-headers :pointer) ; BYTE*
(dw-response-headers-size :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $AppCacheCreateAndCommitFile = Win32::API::More->new('WININET',
'DWORD AppCacheCreateAndCommitFile(LPVOID hAppCache, LPCWSTR pwszSourceFilePath, LPCWSTR pwszUrl, LPVOID pbResponseHeaders, DWORD dwResponseHeadersSize)');
# my $ret = $AppCacheCreateAndCommitFile->Call($hAppCache, $pwszSourceFilePath, $pwszUrl, $pbResponseHeaders, $dwResponseHeadersSize);
# hAppCache : void* -> LPVOID
# pwszSourceFilePath : LPCWSTR -> LPCWSTR
# pwszUrl : LPCWSTR -> LPCWSTR
# pbResponseHeaders : BYTE* -> LPVOID
# dwResponseHeadersSize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。