ホーム › Networking.WinSock › EnumProtocolsA
EnumProtocolsA
関数システムが提供するプロトコル情報を列挙する。
シグネチャ
// MSWSOCK.dll (ANSI / -A)
#include <windows.h>
INT EnumProtocolsA(
INT* lpiProtocols, // optional
void* lpProtocolBuffer,
DWORD* lpdwBufferLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpiProtocols | INT* | inoptional |
| lpProtocolBuffer | void* | out |
| lpdwBufferLength | DWORD* | inout |
戻り値の型: INT
各言語での呼び出し定義
// MSWSOCK.dll (ANSI / -A)
#include <windows.h>
INT EnumProtocolsA(
INT* lpiProtocols, // optional
void* lpProtocolBuffer,
DWORD* lpdwBufferLength
);[DllImport("MSWSOCK.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern int EnumProtocolsA(
IntPtr lpiProtocols, // INT* optional
IntPtr lpProtocolBuffer, // void* out
ref uint lpdwBufferLength // DWORD* in/out
);<DllImport("MSWSOCK.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function EnumProtocolsA(
lpiProtocols As IntPtr, ' INT* optional
lpProtocolBuffer As IntPtr, ' void* out
ByRef lpdwBufferLength As UInteger ' DWORD* in/out
) As Integer
End Function' lpiProtocols : INT* optional
' lpProtocolBuffer : void* out
' lpdwBufferLength : DWORD* in/out
Declare PtrSafe Function EnumProtocolsA Lib "mswsock" ( _
ByVal lpiProtocols As LongPtr, _
ByVal lpProtocolBuffer As LongPtr, _
ByRef lpdwBufferLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EnumProtocolsA = ctypes.windll.mswsock.EnumProtocolsA
EnumProtocolsA.restype = ctypes.c_int
EnumProtocolsA.argtypes = [
ctypes.POINTER(ctypes.c_int), # lpiProtocols : INT* optional
ctypes.POINTER(None), # lpProtocolBuffer : void* out
ctypes.POINTER(wintypes.DWORD), # lpdwBufferLength : DWORD* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSWSOCK.dll')
EnumProtocolsA = Fiddle::Function.new(
lib['EnumProtocolsA'],
[
Fiddle::TYPE_VOIDP, # lpiProtocols : INT* optional
Fiddle::TYPE_VOIDP, # lpProtocolBuffer : void* out
Fiddle::TYPE_VOIDP, # lpdwBufferLength : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "mswsock")]
extern "system" {
fn EnumProtocolsA(
lpiProtocols: *mut i32, // INT* optional
lpProtocolBuffer: *mut (), // void* out
lpdwBufferLength: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSWSOCK.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern int EnumProtocolsA(IntPtr lpiProtocols, IntPtr lpProtocolBuffer, ref uint lpdwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSWSOCK_EnumProtocolsA' -Namespace Win32 -PassThru
# $api::EnumProtocolsA(lpiProtocols, lpProtocolBuffer, lpdwBufferLength)#uselib "MSWSOCK.dll"
#func global EnumProtocolsA "EnumProtocolsA" sptr, sptr, sptr
; EnumProtocolsA varptr(lpiProtocols), lpProtocolBuffer, varptr(lpdwBufferLength) ; 戻り値は stat
; lpiProtocols : INT* optional -> "sptr"
; lpProtocolBuffer : void* out -> "sptr"
; lpdwBufferLength : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MSWSOCK.dll" #cfunc global EnumProtocolsA "EnumProtocolsA" var, sptr, var ; res = EnumProtocolsA(lpiProtocols, lpProtocolBuffer, lpdwBufferLength) ; lpiProtocols : INT* optional -> "var" ; lpProtocolBuffer : void* out -> "sptr" ; lpdwBufferLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MSWSOCK.dll" #cfunc global EnumProtocolsA "EnumProtocolsA" sptr, sptr, sptr ; res = EnumProtocolsA(varptr(lpiProtocols), lpProtocolBuffer, varptr(lpdwBufferLength)) ; lpiProtocols : INT* optional -> "sptr" ; lpProtocolBuffer : void* out -> "sptr" ; lpdwBufferLength : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT EnumProtocolsA(INT* lpiProtocols, void* lpProtocolBuffer, DWORD* lpdwBufferLength) #uselib "MSWSOCK.dll" #cfunc global EnumProtocolsA "EnumProtocolsA" var, intptr, var ; res = EnumProtocolsA(lpiProtocols, lpProtocolBuffer, lpdwBufferLength) ; lpiProtocols : INT* optional -> "var" ; lpProtocolBuffer : void* out -> "intptr" ; lpdwBufferLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT EnumProtocolsA(INT* lpiProtocols, void* lpProtocolBuffer, DWORD* lpdwBufferLength) #uselib "MSWSOCK.dll" #cfunc global EnumProtocolsA "EnumProtocolsA" intptr, intptr, intptr ; res = EnumProtocolsA(varptr(lpiProtocols), lpProtocolBuffer, varptr(lpdwBufferLength)) ; lpiProtocols : INT* optional -> "intptr" ; lpProtocolBuffer : void* out -> "intptr" ; lpdwBufferLength : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mswsock = windows.NewLazySystemDLL("MSWSOCK.dll")
procEnumProtocolsA = mswsock.NewProc("EnumProtocolsA")
)
// lpiProtocols (INT* optional), lpProtocolBuffer (void* out), lpdwBufferLength (DWORD* in/out)
r1, _, err := procEnumProtocolsA.Call(
uintptr(lpiProtocols),
uintptr(lpProtocolBuffer),
uintptr(lpdwBufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction EnumProtocolsA(
lpiProtocols: Pointer; // INT* optional
lpProtocolBuffer: Pointer; // void* out
lpdwBufferLength: Pointer // DWORD* in/out
): Integer; stdcall;
external 'MSWSOCK.dll' name 'EnumProtocolsA';result := DllCall("MSWSOCK\EnumProtocolsA"
, "Ptr", lpiProtocols ; INT* optional
, "Ptr", lpProtocolBuffer ; void* out
, "Ptr", lpdwBufferLength ; DWORD* in/out
, "Int") ; return: INT●EnumProtocolsA(lpiProtocols, lpProtocolBuffer, lpdwBufferLength) = DLL("MSWSOCK.dll", "int EnumProtocolsA(void*, void*, void*)")
# 呼び出し: EnumProtocolsA(lpiProtocols, lpProtocolBuffer, lpdwBufferLength)
# lpiProtocols : INT* optional -> "void*"
# lpProtocolBuffer : void* out -> "void*"
# lpdwBufferLength : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。