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

WsCreateChannel

関数
通信チャネルを作成する。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WsCreateChannel(
    WS_CHANNEL_TYPE channelType,
    WS_CHANNEL_BINDING channelBinding,
    const WS_CHANNEL_PROPERTY* properties,   // optional
    DWORD propertyCount,
    const WS_SECURITY_DESCRIPTION* securityDescription,   // optional
    WS_CHANNEL** channel,
    WS_ERROR* error   // optional
);

パラメーター

名前方向
channelTypeWS_CHANNEL_TYPEin
channelBindingWS_CHANNEL_BINDINGin
propertiesWS_CHANNEL_PROPERTY*inoptional
propertyCountDWORDin
securityDescriptionWS_SECURITY_DESCRIPTION*inoptional
channelWS_CHANNEL**out
errorWS_ERROR*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsCreateChannel(
    WS_CHANNEL_TYPE channelType,
    WS_CHANNEL_BINDING channelBinding,
    const WS_CHANNEL_PROPERTY* properties,   // optional
    DWORD propertyCount,
    const WS_SECURITY_DESCRIPTION* securityDescription,   // optional
    WS_CHANNEL** channel,
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsCreateChannel(
    int channelType,   // WS_CHANNEL_TYPE
    int channelBinding,   // WS_CHANNEL_BINDING
    IntPtr properties,   // WS_CHANNEL_PROPERTY* optional
    uint propertyCount,   // DWORD
    IntPtr securityDescription,   // WS_SECURITY_DESCRIPTION* optional
    IntPtr channel,   // WS_CHANNEL** out
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsCreateChannel(
    channelType As Integer,   ' WS_CHANNEL_TYPE
    channelBinding As Integer,   ' WS_CHANNEL_BINDING
    properties As IntPtr,   ' WS_CHANNEL_PROPERTY* optional
    propertyCount As UInteger,   ' DWORD
    securityDescription As IntPtr,   ' WS_SECURITY_DESCRIPTION* optional
    channel As IntPtr,   ' WS_CHANNEL** out
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' channelType : WS_CHANNEL_TYPE
' channelBinding : WS_CHANNEL_BINDING
' properties : WS_CHANNEL_PROPERTY* optional
' propertyCount : DWORD
' securityDescription : WS_SECURITY_DESCRIPTION* optional
' channel : WS_CHANNEL** out
' error : WS_ERROR* optional
Declare PtrSafe Function WsCreateChannel Lib "webservices" ( _
    ByVal channelType As Long, _
    ByVal channelBinding As Long, _
    ByVal properties As LongPtr, _
    ByVal propertyCount As Long, _
    ByVal securityDescription As LongPtr, _
    ByVal channel 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

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

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

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsCreateChannel = webservices.NewProc("WsCreateChannel")
)

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