Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WsCreateListener

WsCreateListener

関数
接続受け付け用のリスナーを作成する。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

// webservices.dll
#include <windows.h>

HRESULT WsCreateListener(
    WS_CHANNEL_TYPE channelType,
    WS_CHANNEL_BINDING channelBinding,
    const WS_LISTENER_PROPERTY* properties,   // optional
    DWORD propertyCount,
    const WS_SECURITY_DESCRIPTION* securityDescription,   // optional
    WS_LISTENER** listener,
    WS_ERROR* error   // optional
);

パラメーター

名前方向
channelTypeWS_CHANNEL_TYPEin
channelBindingWS_CHANNEL_BINDINGin
propertiesWS_LISTENER_PROPERTY*inoptional
propertyCountDWORDin
securityDescriptionWS_SECURITY_DESCRIPTION*inoptional
listenerWS_LISTENER**out
errorWS_ERROR*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

// webservices.dll
#include <windows.h>

HRESULT WsCreateListener(
    WS_CHANNEL_TYPE channelType,
    WS_CHANNEL_BINDING channelBinding,
    const WS_LISTENER_PROPERTY* properties,   // optional
    DWORD propertyCount,
    const WS_SECURITY_DESCRIPTION* securityDescription,   // optional
    WS_LISTENER** listener,
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsCreateListener(
    int channelType,   // WS_CHANNEL_TYPE
    int channelBinding,   // WS_CHANNEL_BINDING
    IntPtr properties,   // WS_LISTENER_PROPERTY* optional
    uint propertyCount,   // DWORD
    IntPtr securityDescription,   // WS_SECURITY_DESCRIPTION* optional
    IntPtr listener,   // WS_LISTENER** out
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsCreateListener(
    channelType As Integer,   ' WS_CHANNEL_TYPE
    channelBinding As Integer,   ' WS_CHANNEL_BINDING
    properties As IntPtr,   ' WS_LISTENER_PROPERTY* optional
    propertyCount As UInteger,   ' DWORD
    securityDescription As IntPtr,   ' WS_SECURITY_DESCRIPTION* optional
    listener As IntPtr,   ' WS_LISTENER** out
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' channelType : WS_CHANNEL_TYPE
' channelBinding : WS_CHANNEL_BINDING
' properties : WS_LISTENER_PROPERTY* optional
' propertyCount : DWORD
' securityDescription : WS_SECURITY_DESCRIPTION* optional
' listener : WS_LISTENER** out
' error : WS_ERROR* optional
Declare PtrSafe Function WsCreateListener Lib "webservices" ( _
    ByVal channelType As Long, _
    ByVal channelBinding As Long, _
    ByVal properties As LongPtr, _
    ByVal propertyCount As Long, _
    ByVal securityDescription As LongPtr, _
    ByVal listener As LongPtr, _
    ByVal error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WsCreateListener = ctypes.windll.webservices.WsCreateListener
WsCreateListener.restype = ctypes.c_int
WsCreateListener.argtypes = [
    ctypes.c_int,  # channelType : WS_CHANNEL_TYPE
    ctypes.c_int,  # channelBinding : WS_CHANNEL_BINDING
    ctypes.c_void_p,  # properties : WS_LISTENER_PROPERTY* optional
    wintypes.DWORD,  # propertyCount : DWORD
    ctypes.c_void_p,  # securityDescription : WS_SECURITY_DESCRIPTION* optional
    ctypes.c_void_p,  # listener : WS_LISTENER** out
    ctypes.c_void_p,  # error : WS_ERROR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webservices.dll')
WsCreateListener = Fiddle::Function.new(
  lib['WsCreateListener'],
  [
    Fiddle::TYPE_INT,  # channelType : WS_CHANNEL_TYPE
    Fiddle::TYPE_INT,  # channelBinding : WS_CHANNEL_BINDING
    Fiddle::TYPE_VOIDP,  # properties : WS_LISTENER_PROPERTY* optional
    -Fiddle::TYPE_INT,  # propertyCount : DWORD
    Fiddle::TYPE_VOIDP,  # securityDescription : WS_SECURITY_DESCRIPTION* optional
    Fiddle::TYPE_VOIDP,  # listener : WS_LISTENER** out
    Fiddle::TYPE_VOIDP,  # error : WS_ERROR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "webservices")]
extern "system" {
    fn WsCreateListener(
        channelType: i32,  // WS_CHANNEL_TYPE
        channelBinding: i32,  // WS_CHANNEL_BINDING
        properties: *const WS_LISTENER_PROPERTY,  // WS_LISTENER_PROPERTY* optional
        propertyCount: u32,  // DWORD
        securityDescription: *const WS_SECURITY_DESCRIPTION,  // WS_SECURITY_DESCRIPTION* optional
        listener: *mut *mut isize,  // WS_LISTENER** out
        error: *mut isize  // WS_ERROR* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("webservices.dll")]
public static extern int WsCreateListener(int channelType, int channelBinding, IntPtr properties, uint propertyCount, IntPtr securityDescription, IntPtr listener, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsCreateListener' -Namespace Win32 -PassThru
# $api::WsCreateListener(channelType, channelBinding, properties, propertyCount, securityDescription, listener, error)
#uselib "webservices.dll"
#func global WsCreateListener "WsCreateListener" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WsCreateListener channelType, channelBinding, varptr(properties), propertyCount, varptr(securityDescription), listener, error   ; 戻り値は stat
; channelType : WS_CHANNEL_TYPE -> "sptr"
; channelBinding : WS_CHANNEL_BINDING -> "sptr"
; properties : WS_LISTENER_PROPERTY* optional -> "sptr"
; propertyCount : DWORD -> "sptr"
; securityDescription : WS_SECURITY_DESCRIPTION* optional -> "sptr"
; listener : WS_LISTENER** out -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "webservices.dll"
#cfunc global WsCreateListener "WsCreateListener" int, int, var, int, var, int, int
; res = WsCreateListener(channelType, channelBinding, properties, propertyCount, securityDescription, listener, error)
; channelType : WS_CHANNEL_TYPE -> "int"
; channelBinding : WS_CHANNEL_BINDING -> "int"
; properties : WS_LISTENER_PROPERTY* optional -> "var"
; propertyCount : DWORD -> "int"
; securityDescription : WS_SECURITY_DESCRIPTION* optional -> "var"
; listener : WS_LISTENER** out -> "int"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WsCreateListener(WS_CHANNEL_TYPE channelType, WS_CHANNEL_BINDING channelBinding, WS_LISTENER_PROPERTY* properties, DWORD propertyCount, WS_SECURITY_DESCRIPTION* securityDescription, WS_LISTENER** listener, WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsCreateListener "WsCreateListener" int, int, var, int, var, int, int
; res = WsCreateListener(channelType, channelBinding, properties, propertyCount, securityDescription, listener, error)
; channelType : WS_CHANNEL_TYPE -> "int"
; channelBinding : WS_CHANNEL_BINDING -> "int"
; properties : WS_LISTENER_PROPERTY* optional -> "var"
; propertyCount : DWORD -> "int"
; securityDescription : WS_SECURITY_DESCRIPTION* optional -> "var"
; listener : WS_LISTENER** out -> "int"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsCreateListener = webservices.NewProc("WsCreateListener")
)

// channelType (WS_CHANNEL_TYPE), channelBinding (WS_CHANNEL_BINDING), properties (WS_LISTENER_PROPERTY* optional), propertyCount (DWORD), securityDescription (WS_SECURITY_DESCRIPTION* optional), listener (WS_LISTENER** out), error (WS_ERROR* optional)
r1, _, err := procWsCreateListener.Call(
	uintptr(channelType),
	uintptr(channelBinding),
	uintptr(properties),
	uintptr(propertyCount),
	uintptr(securityDescription),
	uintptr(listener),
	uintptr(error),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WsCreateListener(
  channelType: Integer;   // WS_CHANNEL_TYPE
  channelBinding: Integer;   // WS_CHANNEL_BINDING
  properties: Pointer;   // WS_LISTENER_PROPERTY* optional
  propertyCount: DWORD;   // DWORD
  securityDescription: Pointer;   // WS_SECURITY_DESCRIPTION* optional
  listener: Pointer;   // WS_LISTENER** out
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsCreateListener';
result := DllCall("webservices\WsCreateListener"
    , "Int", channelType   ; WS_CHANNEL_TYPE
    , "Int", channelBinding   ; WS_CHANNEL_BINDING
    , "Ptr", properties   ; WS_LISTENER_PROPERTY* optional
    , "UInt", propertyCount   ; DWORD
    , "Ptr", securityDescription   ; WS_SECURITY_DESCRIPTION* optional
    , "Ptr", listener   ; WS_LISTENER** out
    , "Ptr", error   ; WS_ERROR* optional
    , "Int")   ; return: HRESULT
●WsCreateListener(channelType, channelBinding, properties, propertyCount, securityDescription, listener, error) = DLL("webservices.dll", "int WsCreateListener(int, int, void*, dword, void*, void*, void*)")
# 呼び出し: WsCreateListener(channelType, channelBinding, properties, propertyCount, securityDescription, listener, error)
# channelType : WS_CHANNEL_TYPE -> "int"
# channelBinding : WS_CHANNEL_BINDING -> "int"
# properties : WS_LISTENER_PROPERTY* optional -> "void*"
# propertyCount : DWORD -> "dword"
# securityDescription : WS_SECURITY_DESCRIPTION* optional -> "void*"
# listener : WS_LISTENER** out -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。