ホーム › System.Mailslots › CreateMailslotA
CreateMailslotA
関数ANSI名でメールスロットを作成する。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
HANDLE CreateMailslotA(
LPCSTR lpName,
DWORD nMaxMessageSize,
DWORD lReadTimeout,
SECURITY_ATTRIBUTES* lpSecurityAttributes // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpName | LPCSTR | in |
| nMaxMessageSize | DWORD | in |
| lReadTimeout | DWORD | in |
| lpSecurityAttributes | SECURITY_ATTRIBUTES* | inoptional |
戻り値の型: HANDLE
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
HANDLE CreateMailslotA(
LPCSTR lpName,
DWORD nMaxMessageSize,
DWORD lReadTimeout,
SECURITY_ATTRIBUTES* lpSecurityAttributes // optional
);[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateMailslotA(
[MarshalAs(UnmanagedType.LPStr)] string lpName, // LPCSTR
uint nMaxMessageSize, // DWORD
uint lReadTimeout, // DWORD
IntPtr lpSecurityAttributes // SECURITY_ATTRIBUTES* optional
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateMailslotA(
<MarshalAs(UnmanagedType.LPStr)> lpName As String, ' LPCSTR
nMaxMessageSize As UInteger, ' DWORD
lReadTimeout As UInteger, ' DWORD
lpSecurityAttributes As IntPtr ' SECURITY_ATTRIBUTES* optional
) As IntPtr
End Function' lpName : LPCSTR
' nMaxMessageSize : DWORD
' lReadTimeout : DWORD
' lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
Declare PtrSafe Function CreateMailslotA Lib "kernel32" ( _
ByVal lpName As String, _
ByVal nMaxMessageSize As Long, _
ByVal lReadTimeout As Long, _
ByVal lpSecurityAttributes As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateMailslotA = ctypes.windll.kernel32.CreateMailslotA
CreateMailslotA.restype = ctypes.c_void_p
CreateMailslotA.argtypes = [
wintypes.LPCSTR, # lpName : LPCSTR
wintypes.DWORD, # nMaxMessageSize : DWORD
wintypes.DWORD, # lReadTimeout : DWORD
ctypes.c_void_p, # lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
CreateMailslotA = Fiddle::Function.new(
lib['CreateMailslotA'],
[
Fiddle::TYPE_VOIDP, # lpName : LPCSTR
-Fiddle::TYPE_INT, # nMaxMessageSize : DWORD
-Fiddle::TYPE_INT, # lReadTimeout : DWORD
Fiddle::TYPE_VOIDP, # lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn CreateMailslotA(
lpName: *const u8, // LPCSTR
nMaxMessageSize: u32, // DWORD
lReadTimeout: u32, // DWORD
lpSecurityAttributes: *mut SECURITY_ATTRIBUTES // SECURITY_ATTRIBUTES* optional
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr CreateMailslotA([MarshalAs(UnmanagedType.LPStr)] string lpName, uint nMaxMessageSize, uint lReadTimeout, IntPtr lpSecurityAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreateMailslotA' -Namespace Win32 -PassThru
# $api::CreateMailslotA(lpName, nMaxMessageSize, lReadTimeout, lpSecurityAttributes)#uselib "KERNEL32.dll"
#func global CreateMailslotA "CreateMailslotA" sptr, sptr, sptr, sptr
; CreateMailslotA lpName, nMaxMessageSize, lReadTimeout, varptr(lpSecurityAttributes) ; 戻り値は stat
; lpName : LPCSTR -> "sptr"
; nMaxMessageSize : DWORD -> "sptr"
; lReadTimeout : DWORD -> "sptr"
; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global CreateMailslotA "CreateMailslotA" str, int, int, var ; res = CreateMailslotA(lpName, nMaxMessageSize, lReadTimeout, lpSecurityAttributes) ; lpName : LPCSTR -> "str" ; nMaxMessageSize : DWORD -> "int" ; lReadTimeout : DWORD -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global CreateMailslotA "CreateMailslotA" str, int, int, sptr ; res = CreateMailslotA(lpName, nMaxMessageSize, lReadTimeout, varptr(lpSecurityAttributes)) ; lpName : LPCSTR -> "str" ; nMaxMessageSize : DWORD -> "int" ; lReadTimeout : DWORD -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HANDLE CreateMailslotA(LPCSTR lpName, DWORD nMaxMessageSize, DWORD lReadTimeout, SECURITY_ATTRIBUTES* lpSecurityAttributes) #uselib "KERNEL32.dll" #cfunc global CreateMailslotA "CreateMailslotA" str, int, int, var ; res = CreateMailslotA(lpName, nMaxMessageSize, lReadTimeout, lpSecurityAttributes) ; lpName : LPCSTR -> "str" ; nMaxMessageSize : DWORD -> "int" ; lReadTimeout : DWORD -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HANDLE CreateMailslotA(LPCSTR lpName, DWORD nMaxMessageSize, DWORD lReadTimeout, SECURITY_ATTRIBUTES* lpSecurityAttributes) #uselib "KERNEL32.dll" #cfunc global CreateMailslotA "CreateMailslotA" str, int, int, intptr ; res = CreateMailslotA(lpName, nMaxMessageSize, lReadTimeout, varptr(lpSecurityAttributes)) ; lpName : LPCSTR -> "str" ; nMaxMessageSize : DWORD -> "int" ; lReadTimeout : DWORD -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procCreateMailslotA = kernel32.NewProc("CreateMailslotA")
)
// lpName (LPCSTR), nMaxMessageSize (DWORD), lReadTimeout (DWORD), lpSecurityAttributes (SECURITY_ATTRIBUTES* optional)
r1, _, err := procCreateMailslotA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpName))),
uintptr(nMaxMessageSize),
uintptr(lReadTimeout),
uintptr(lpSecurityAttributes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HANDLEfunction CreateMailslotA(
lpName: PAnsiChar; // LPCSTR
nMaxMessageSize: DWORD; // DWORD
lReadTimeout: DWORD; // DWORD
lpSecurityAttributes: Pointer // SECURITY_ATTRIBUTES* optional
): THandle; stdcall;
external 'KERNEL32.dll' name 'CreateMailslotA';result := DllCall("KERNEL32\CreateMailslotA"
, "AStr", lpName ; LPCSTR
, "UInt", nMaxMessageSize ; DWORD
, "UInt", lReadTimeout ; DWORD
, "Ptr", lpSecurityAttributes ; SECURITY_ATTRIBUTES* optional
, "Ptr") ; return: HANDLE●CreateMailslotA(lpName, nMaxMessageSize, lReadTimeout, lpSecurityAttributes) = DLL("KERNEL32.dll", "void* CreateMailslotA(char*, dword, dword, void*)")
# 呼び出し: CreateMailslotA(lpName, nMaxMessageSize, lReadTimeout, lpSecurityAttributes)
# lpName : LPCSTR -> "char*"
# nMaxMessageSize : DWORD -> "dword"
# lReadTimeout : DWORD -> "dword"
# lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。