ホーム › System.WindowsProgramming › _hread
_hread
関数ファイルから大きなバイト数を読み込む旧式関数。
シグネチャ
// KERNEL32.dll
#include <windows.h>
INT _hread(
INT hFile,
void* lpBuffer,
INT lBytes
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hFile | INT | in |
| lpBuffer | void* | out |
| lBytes | INT | in |
戻り値の型: INT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
INT _hread(
INT hFile,
void* lpBuffer,
INT lBytes
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern int _hread(
int hFile, // INT
IntPtr lpBuffer, // void* out
int lBytes // INT
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function _hread(
hFile As Integer, ' INT
lpBuffer As IntPtr, ' void* out
lBytes As Integer ' INT
) As Integer
End Function' hFile : INT
' lpBuffer : void* out
' lBytes : INT
Declare PtrSafe Function _hread Lib "kernel32" ( _
ByVal hFile As Long, _
ByVal lpBuffer As LongPtr, _
ByVal lBytes As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
_hread = ctypes.windll.kernel32._hread
_hread.restype = ctypes.c_int
_hread.argtypes = [
ctypes.c_int, # hFile : INT
ctypes.POINTER(None), # lpBuffer : void* out
ctypes.c_int, # lBytes : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
_hread = Fiddle::Function.new(
lib['_hread'],
[
Fiddle::TYPE_INT, # hFile : INT
Fiddle::TYPE_VOIDP, # lpBuffer : void* out
Fiddle::TYPE_INT, # lBytes : INT
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn _hread(
hFile: i32, // INT
lpBuffer: *mut (), // void* out
lBytes: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern int _hread(int hFile, IntPtr lpBuffer, int lBytes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32__hread' -Namespace Win32 -PassThru
# $api::_hread(hFile, lpBuffer, lBytes)#uselib "KERNEL32.dll"
#func global _hread "_hread" sptr, sptr, sptr
; _hread hFile, lpBuffer, lBytes ; 戻り値は stat
; hFile : INT -> "sptr"
; lpBuffer : void* out -> "sptr"
; lBytes : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global _hread "_hread" int, sptr, int
; res = _hread(hFile, lpBuffer, lBytes)
; hFile : INT -> "int"
; lpBuffer : void* out -> "sptr"
; lBytes : INT -> "int"; INT _hread(INT hFile, void* lpBuffer, INT lBytes)
#uselib "KERNEL32.dll"
#cfunc global _hread "_hread" int, intptr, int
; res = _hread(hFile, lpBuffer, lBytes)
; hFile : INT -> "int"
; lpBuffer : void* out -> "intptr"
; lBytes : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
proc_hread = kernel32.NewProc("_hread")
)
// hFile (INT), lpBuffer (void* out), lBytes (INT)
r1, _, err := proc_hread.Call(
uintptr(hFile),
uintptr(lpBuffer),
uintptr(lBytes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction _hread(
hFile: Integer; // INT
lpBuffer: Pointer; // void* out
lBytes: Integer // INT
): Integer; stdcall;
external 'KERNEL32.dll' name '_hread';result := DllCall("KERNEL32\_hread"
, "Int", hFile ; INT
, "Ptr", lpBuffer ; void* out
, "Int", lBytes ; INT
, "Int") ; return: INT●_hread(hFile, lpBuffer, lBytes) = DLL("KERNEL32.dll", "int _hread(int, void*, int)")
# 呼び出し: _hread(hFile, lpBuffer, lBytes)
# hFile : INT -> "int"
# lpBuffer : void* out -> "void*"
# lBytes : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。