ホーム › System.Memory › FlushViewOfFile
FlushViewOfFile
関数マップされたビューの変更内容をディスク上のファイルへ書き込む。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL FlushViewOfFile(
const void* lpBaseAddress,
UINT_PTR dwNumberOfBytesToFlush
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpBaseAddress | void* | in |
| dwNumberOfBytesToFlush | UINT_PTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL FlushViewOfFile(
const void* lpBaseAddress,
UINT_PTR dwNumberOfBytesToFlush
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool FlushViewOfFile(
IntPtr lpBaseAddress, // void*
UIntPtr dwNumberOfBytesToFlush // UINT_PTR
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FlushViewOfFile(
lpBaseAddress As IntPtr, ' void*
dwNumberOfBytesToFlush As UIntPtr ' UINT_PTR
) As Boolean
End Function' lpBaseAddress : void*
' dwNumberOfBytesToFlush : UINT_PTR
Declare PtrSafe Function FlushViewOfFile Lib "kernel32" ( _
ByVal lpBaseAddress As LongPtr, _
ByVal dwNumberOfBytesToFlush As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FlushViewOfFile = ctypes.windll.kernel32.FlushViewOfFile
FlushViewOfFile.restype = wintypes.BOOL
FlushViewOfFile.argtypes = [
ctypes.POINTER(None), # lpBaseAddress : void*
ctypes.c_size_t, # dwNumberOfBytesToFlush : UINT_PTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
FlushViewOfFile = Fiddle::Function.new(
lib['FlushViewOfFile'],
[
Fiddle::TYPE_VOIDP, # lpBaseAddress : void*
Fiddle::TYPE_UINTPTR_T, # dwNumberOfBytesToFlush : UINT_PTR
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn FlushViewOfFile(
lpBaseAddress: *const (), // void*
dwNumberOfBytesToFlush: usize // UINT_PTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool FlushViewOfFile(IntPtr lpBaseAddress, UIntPtr dwNumberOfBytesToFlush);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_FlushViewOfFile' -Namespace Win32 -PassThru
# $api::FlushViewOfFile(lpBaseAddress, dwNumberOfBytesToFlush)#uselib "KERNEL32.dll"
#func global FlushViewOfFile "FlushViewOfFile" sptr, sptr
; FlushViewOfFile lpBaseAddress, dwNumberOfBytesToFlush ; 戻り値は stat
; lpBaseAddress : void* -> "sptr"
; dwNumberOfBytesToFlush : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global FlushViewOfFile "FlushViewOfFile" sptr, sptr
; res = FlushViewOfFile(lpBaseAddress, dwNumberOfBytesToFlush)
; lpBaseAddress : void* -> "sptr"
; dwNumberOfBytesToFlush : UINT_PTR -> "sptr"; BOOL FlushViewOfFile(void* lpBaseAddress, UINT_PTR dwNumberOfBytesToFlush)
#uselib "KERNEL32.dll"
#cfunc global FlushViewOfFile "FlushViewOfFile" intptr, intptr
; res = FlushViewOfFile(lpBaseAddress, dwNumberOfBytesToFlush)
; lpBaseAddress : void* -> "intptr"
; dwNumberOfBytesToFlush : UINT_PTR -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procFlushViewOfFile = kernel32.NewProc("FlushViewOfFile")
)
// lpBaseAddress (void*), dwNumberOfBytesToFlush (UINT_PTR)
r1, _, err := procFlushViewOfFile.Call(
uintptr(lpBaseAddress),
uintptr(dwNumberOfBytesToFlush),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction FlushViewOfFile(
lpBaseAddress: Pointer; // void*
dwNumberOfBytesToFlush: NativeUInt // UINT_PTR
): BOOL; stdcall;
external 'KERNEL32.dll' name 'FlushViewOfFile';result := DllCall("KERNEL32\FlushViewOfFile"
, "Ptr", lpBaseAddress ; void*
, "UPtr", dwNumberOfBytesToFlush ; UINT_PTR
, "Int") ; return: BOOL●FlushViewOfFile(lpBaseAddress, dwNumberOfBytesToFlush) = DLL("KERNEL32.dll", "bool FlushViewOfFile(void*, int)")
# 呼び出し: FlushViewOfFile(lpBaseAddress, dwNumberOfBytesToFlush)
# lpBaseAddress : void* -> "void*"
# dwNumberOfBytesToFlush : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。