ホーム › Networking.WinSock › EnumProtocolsW
EnumProtocolsW
関数システムが提供するプロトコル情報を列挙する。
シグネチャ
// MSWSOCK.dll (Unicode / -W)
#include <windows.h>
INT EnumProtocolsW(
INT* lpiProtocols, // optional
void* lpProtocolBuffer,
DWORD* lpdwBufferLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpiProtocols | INT* | inoptional |
| lpProtocolBuffer | void* | out |
| lpdwBufferLength | DWORD* | inout |
戻り値の型: INT
各言語での呼び出し定義
// MSWSOCK.dll (Unicode / -W)
#include <windows.h>
INT EnumProtocolsW(
INT* lpiProtocols, // optional
void* lpProtocolBuffer,
DWORD* lpdwBufferLength
);[DllImport("MSWSOCK.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern int EnumProtocolsW(
IntPtr lpiProtocols, // INT* optional
IntPtr lpProtocolBuffer, // void* out
ref uint lpdwBufferLength // DWORD* in/out
);<DllImport("MSWSOCK.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function EnumProtocolsW(
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 EnumProtocolsW Lib "mswsock" ( _
ByVal lpiProtocols As LongPtr, _
ByVal lpProtocolBuffer As LongPtr, _
ByRef lpdwBufferLength As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EnumProtocolsW = ctypes.windll.mswsock.EnumProtocolsW
EnumProtocolsW.restype = ctypes.c_int
EnumProtocolsW.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')
EnumProtocolsW = Fiddle::Function.new(
lib['EnumProtocolsW'],
[
Fiddle::TYPE_VOIDP, # lpiProtocols : INT* optional
Fiddle::TYPE_VOIDP, # lpProtocolBuffer : void* out
Fiddle::TYPE_VOIDP, # lpdwBufferLength : DWORD* in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "mswsock")]
extern "system" {
fn EnumProtocolsW(
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.Unicode, SetLastError = true)]
public static extern int EnumProtocolsW(IntPtr lpiProtocols, IntPtr lpProtocolBuffer, ref uint lpdwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSWSOCK_EnumProtocolsW' -Namespace Win32 -PassThru
# $api::EnumProtocolsW(lpiProtocols, lpProtocolBuffer, lpdwBufferLength)#uselib "MSWSOCK.dll"
#func global EnumProtocolsW "EnumProtocolsW" wptr, wptr, wptr
; EnumProtocolsW varptr(lpiProtocols), lpProtocolBuffer, varptr(lpdwBufferLength) ; 戻り値は stat
; lpiProtocols : INT* optional -> "wptr"
; lpProtocolBuffer : void* out -> "wptr"
; lpdwBufferLength : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MSWSOCK.dll" #cfunc global EnumProtocolsW "EnumProtocolsW" var, sptr, var ; res = EnumProtocolsW(lpiProtocols, lpProtocolBuffer, lpdwBufferLength) ; lpiProtocols : INT* optional -> "var" ; lpProtocolBuffer : void* out -> "sptr" ; lpdwBufferLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MSWSOCK.dll" #cfunc global EnumProtocolsW "EnumProtocolsW" sptr, sptr, sptr ; res = EnumProtocolsW(varptr(lpiProtocols), lpProtocolBuffer, varptr(lpdwBufferLength)) ; lpiProtocols : INT* optional -> "sptr" ; lpProtocolBuffer : void* out -> "sptr" ; lpdwBufferLength : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT EnumProtocolsW(INT* lpiProtocols, void* lpProtocolBuffer, DWORD* lpdwBufferLength) #uselib "MSWSOCK.dll" #cfunc global EnumProtocolsW "EnumProtocolsW" var, intptr, var ; res = EnumProtocolsW(lpiProtocols, lpProtocolBuffer, lpdwBufferLength) ; lpiProtocols : INT* optional -> "var" ; lpProtocolBuffer : void* out -> "intptr" ; lpdwBufferLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT EnumProtocolsW(INT* lpiProtocols, void* lpProtocolBuffer, DWORD* lpdwBufferLength) #uselib "MSWSOCK.dll" #cfunc global EnumProtocolsW "EnumProtocolsW" intptr, intptr, intptr ; res = EnumProtocolsW(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")
procEnumProtocolsW = mswsock.NewProc("EnumProtocolsW")
)
// lpiProtocols (INT* optional), lpProtocolBuffer (void* out), lpdwBufferLength (DWORD* in/out)
r1, _, err := procEnumProtocolsW.Call(
uintptr(lpiProtocols),
uintptr(lpProtocolBuffer),
uintptr(lpdwBufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction EnumProtocolsW(
lpiProtocols: Pointer; // INT* optional
lpProtocolBuffer: Pointer; // void* out
lpdwBufferLength: Pointer // DWORD* in/out
): Integer; stdcall;
external 'MSWSOCK.dll' name 'EnumProtocolsW';result := DllCall("MSWSOCK\EnumProtocolsW"
, "Ptr", lpiProtocols ; INT* optional
, "Ptr", lpProtocolBuffer ; void* out
, "Ptr", lpdwBufferLength ; DWORD* in/out
, "Int") ; return: INT●EnumProtocolsW(lpiProtocols, lpProtocolBuffer, lpdwBufferLength) = DLL("MSWSOCK.dll", "int EnumProtocolsW(void*, void*, void*)")
# 呼び出し: EnumProtocolsW(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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。