ホーム › Networking.WindowsWebServices › WsReceiveMessage
WsReceiveMessage
関数チャネル経由でメッセージを受信する。
シグネチャ
// webservices.dll
#include <windows.h>
HRESULT WsReceiveMessage(
WS_CHANNEL* channel,
WS_MESSAGE* message,
const WS_MESSAGE_DESCRIPTION** messageDescriptions,
DWORD messageDescriptionCount,
WS_RECEIVE_OPTION receiveOption,
WS_READ_OPTION readBodyOption,
WS_HEAP* heap, // optional
void* value,
DWORD valueSize,
DWORD* index, // optional
const WS_ASYNC_CONTEXT* asyncContext, // optional
WS_ERROR* error // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| channel | WS_CHANNEL* | in |
| message | WS_MESSAGE* | in |
| messageDescriptions | WS_MESSAGE_DESCRIPTION** | in |
| messageDescriptionCount | DWORD | in |
| receiveOption | WS_RECEIVE_OPTION | in |
| readBodyOption | WS_READ_OPTION | in |
| heap | WS_HEAP* | inoptional |
| value | void* | out |
| valueSize | DWORD | in |
| index | DWORD* | outoptional |
| asyncContext | WS_ASYNC_CONTEXT* | inoptional |
| error | WS_ERROR* | inoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// webservices.dll
#include <windows.h>
HRESULT WsReceiveMessage(
WS_CHANNEL* channel,
WS_MESSAGE* message,
const WS_MESSAGE_DESCRIPTION** messageDescriptions,
DWORD messageDescriptionCount,
WS_RECEIVE_OPTION receiveOption,
WS_READ_OPTION readBodyOption,
WS_HEAP* heap, // optional
void* value,
DWORD valueSize,
DWORD* index, // optional
const WS_ASYNC_CONTEXT* asyncContext, // optional
WS_ERROR* error // optional
);[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsReceiveMessage(
ref IntPtr channel, // WS_CHANNEL*
ref IntPtr message, // WS_MESSAGE*
IntPtr messageDescriptions, // WS_MESSAGE_DESCRIPTION**
uint messageDescriptionCount, // DWORD
int receiveOption, // WS_RECEIVE_OPTION
int readBodyOption, // WS_READ_OPTION
IntPtr heap, // WS_HEAP* optional
IntPtr value, // void* out
uint valueSize, // DWORD
IntPtr index, // DWORD* optional, out
IntPtr asyncContext, // WS_ASYNC_CONTEXT* optional
IntPtr error // WS_ERROR* optional
);<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsReceiveMessage(
ByRef channel As IntPtr, ' WS_CHANNEL*
ByRef message As IntPtr, ' WS_MESSAGE*
messageDescriptions As IntPtr, ' WS_MESSAGE_DESCRIPTION**
messageDescriptionCount As UInteger, ' DWORD
receiveOption As Integer, ' WS_RECEIVE_OPTION
readBodyOption As Integer, ' WS_READ_OPTION
heap As IntPtr, ' WS_HEAP* optional
value As IntPtr, ' void* out
valueSize As UInteger, ' DWORD
index As IntPtr, ' DWORD* optional, out
asyncContext As IntPtr, ' WS_ASYNC_CONTEXT* optional
[error] As IntPtr ' WS_ERROR* optional
) As Integer
End Function' channel : WS_CHANNEL*
' message : WS_MESSAGE*
' messageDescriptions : WS_MESSAGE_DESCRIPTION**
' messageDescriptionCount : DWORD
' receiveOption : WS_RECEIVE_OPTION
' readBodyOption : WS_READ_OPTION
' heap : WS_HEAP* optional
' value : void* out
' valueSize : DWORD
' index : DWORD* optional, out
' asyncContext : WS_ASYNC_CONTEXT* optional
' error : WS_ERROR* optional
Declare PtrSafe Function WsReceiveMessage Lib "webservices" ( _
ByRef channel As LongPtr, _
ByRef message As LongPtr, _
ByVal messageDescriptions As LongPtr, _
ByVal messageDescriptionCount As Long, _
ByVal receiveOption As Long, _
ByVal readBodyOption As Long, _
ByVal heap As LongPtr, _
ByVal value As LongPtr, _
ByVal valueSize As Long, _
ByVal index As LongPtr, _
ByVal asyncContext 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
WsReceiveMessage = ctypes.windll.webservices.WsReceiveMessage
WsReceiveMessage.restype = ctypes.c_int
WsReceiveMessage.argtypes = [
ctypes.c_void_p, # channel : WS_CHANNEL*
ctypes.c_void_p, # message : WS_MESSAGE*
ctypes.c_void_p, # messageDescriptions : WS_MESSAGE_DESCRIPTION**
wintypes.DWORD, # messageDescriptionCount : DWORD
ctypes.c_int, # receiveOption : WS_RECEIVE_OPTION
ctypes.c_int, # readBodyOption : WS_READ_OPTION
ctypes.c_void_p, # heap : WS_HEAP* optional
ctypes.POINTER(None), # value : void* out
wintypes.DWORD, # valueSize : DWORD
ctypes.POINTER(wintypes.DWORD), # index : DWORD* optional, out
ctypes.c_void_p, # asyncContext : WS_ASYNC_CONTEXT* optional
ctypes.c_void_p, # error : WS_ERROR* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('webservices.dll')
WsReceiveMessage = Fiddle::Function.new(
lib['WsReceiveMessage'],
[
Fiddle::TYPE_VOIDP, # channel : WS_CHANNEL*
Fiddle::TYPE_VOIDP, # message : WS_MESSAGE*
Fiddle::TYPE_VOIDP, # messageDescriptions : WS_MESSAGE_DESCRIPTION**
-Fiddle::TYPE_INT, # messageDescriptionCount : DWORD
Fiddle::TYPE_INT, # receiveOption : WS_RECEIVE_OPTION
Fiddle::TYPE_INT, # readBodyOption : WS_READ_OPTION
Fiddle::TYPE_VOIDP, # heap : WS_HEAP* optional
Fiddle::TYPE_VOIDP, # value : void* out
-Fiddle::TYPE_INT, # valueSize : DWORD
Fiddle::TYPE_VOIDP, # index : DWORD* optional, out
Fiddle::TYPE_VOIDP, # asyncContext : WS_ASYNC_CONTEXT* optional
Fiddle::TYPE_VOIDP, # error : WS_ERROR* optional
],
Fiddle::TYPE_INT)#[link(name = "webservices")]
extern "system" {
fn WsReceiveMessage(
channel: *mut isize, // WS_CHANNEL*
message: *mut isize, // WS_MESSAGE*
messageDescriptions: *const *const WS_MESSAGE_DESCRIPTION, // WS_MESSAGE_DESCRIPTION**
messageDescriptionCount: u32, // DWORD
receiveOption: i32, // WS_RECEIVE_OPTION
readBodyOption: i32, // WS_READ_OPTION
heap: *mut isize, // WS_HEAP* optional
value: *mut (), // void* out
valueSize: u32, // DWORD
index: *mut u32, // DWORD* optional, out
asyncContext: *const WS_ASYNC_CONTEXT, // WS_ASYNC_CONTEXT* optional
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 WsReceiveMessage(ref IntPtr channel, ref IntPtr message, IntPtr messageDescriptions, uint messageDescriptionCount, int receiveOption, int readBodyOption, IntPtr heap, IntPtr value, uint valueSize, IntPtr index, IntPtr asyncContext, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsReceiveMessage' -Namespace Win32 -PassThru
# $api::WsReceiveMessage(channel, message, messageDescriptions, messageDescriptionCount, receiveOption, readBodyOption, heap, value, valueSize, index, asyncContext, error)#uselib "webservices.dll"
#func global WsReceiveMessage "WsReceiveMessage" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WsReceiveMessage channel, message, varptr(messageDescriptions), messageDescriptionCount, receiveOption, readBodyOption, heap, value, valueSize, varptr(index), varptr(asyncContext), error ; 戻り値は stat
; channel : WS_CHANNEL* -> "sptr"
; message : WS_MESSAGE* -> "sptr"
; messageDescriptions : WS_MESSAGE_DESCRIPTION** -> "sptr"
; messageDescriptionCount : DWORD -> "sptr"
; receiveOption : WS_RECEIVE_OPTION -> "sptr"
; readBodyOption : WS_READ_OPTION -> "sptr"
; heap : WS_HEAP* optional -> "sptr"
; value : void* out -> "sptr"
; valueSize : DWORD -> "sptr"
; index : DWORD* optional, out -> "sptr"
; asyncContext : WS_ASYNC_CONTEXT* optional -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "webservices.dll" #cfunc global WsReceiveMessage "WsReceiveMessage" int, int, var, int, int, int, int, sptr, int, var, var, int ; res = WsReceiveMessage(channel, message, messageDescriptions, messageDescriptionCount, receiveOption, readBodyOption, heap, value, valueSize, index, asyncContext, error) ; channel : WS_CHANNEL* -> "int" ; message : WS_MESSAGE* -> "int" ; messageDescriptions : WS_MESSAGE_DESCRIPTION** -> "var" ; messageDescriptionCount : DWORD -> "int" ; receiveOption : WS_RECEIVE_OPTION -> "int" ; readBodyOption : WS_READ_OPTION -> "int" ; heap : WS_HEAP* optional -> "int" ; value : void* out -> "sptr" ; valueSize : DWORD -> "int" ; index : DWORD* optional, out -> "var" ; asyncContext : WS_ASYNC_CONTEXT* optional -> "var" ; error : WS_ERROR* optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "webservices.dll" #cfunc global WsReceiveMessage "WsReceiveMessage" int, int, sptr, int, int, int, int, sptr, int, sptr, sptr, int ; res = WsReceiveMessage(channel, message, varptr(messageDescriptions), messageDescriptionCount, receiveOption, readBodyOption, heap, value, valueSize, varptr(index), varptr(asyncContext), error) ; channel : WS_CHANNEL* -> "int" ; message : WS_MESSAGE* -> "int" ; messageDescriptions : WS_MESSAGE_DESCRIPTION** -> "sptr" ; messageDescriptionCount : DWORD -> "int" ; receiveOption : WS_RECEIVE_OPTION -> "int" ; readBodyOption : WS_READ_OPTION -> "int" ; heap : WS_HEAP* optional -> "int" ; value : void* out -> "sptr" ; valueSize : DWORD -> "int" ; index : DWORD* optional, out -> "sptr" ; asyncContext : WS_ASYNC_CONTEXT* optional -> "sptr" ; error : WS_ERROR* optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WsReceiveMessage(WS_CHANNEL* channel, WS_MESSAGE* message, WS_MESSAGE_DESCRIPTION** messageDescriptions, DWORD messageDescriptionCount, WS_RECEIVE_OPTION receiveOption, WS_READ_OPTION readBodyOption, WS_HEAP* heap, void* value, DWORD valueSize, DWORD* index, WS_ASYNC_CONTEXT* asyncContext, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsReceiveMessage "WsReceiveMessage" int, int, var, int, int, int, int, intptr, int, var, var, int ; res = WsReceiveMessage(channel, message, messageDescriptions, messageDescriptionCount, receiveOption, readBodyOption, heap, value, valueSize, index, asyncContext, error) ; channel : WS_CHANNEL* -> "int" ; message : WS_MESSAGE* -> "int" ; messageDescriptions : WS_MESSAGE_DESCRIPTION** -> "var" ; messageDescriptionCount : DWORD -> "int" ; receiveOption : WS_RECEIVE_OPTION -> "int" ; readBodyOption : WS_READ_OPTION -> "int" ; heap : WS_HEAP* optional -> "int" ; value : void* out -> "intptr" ; valueSize : DWORD -> "int" ; index : DWORD* optional, out -> "var" ; asyncContext : WS_ASYNC_CONTEXT* optional -> "var" ; error : WS_ERROR* optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WsReceiveMessage(WS_CHANNEL* channel, WS_MESSAGE* message, WS_MESSAGE_DESCRIPTION** messageDescriptions, DWORD messageDescriptionCount, WS_RECEIVE_OPTION receiveOption, WS_READ_OPTION readBodyOption, WS_HEAP* heap, void* value, DWORD valueSize, DWORD* index, WS_ASYNC_CONTEXT* asyncContext, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsReceiveMessage "WsReceiveMessage" int, int, intptr, int, int, int, int, intptr, int, intptr, intptr, int ; res = WsReceiveMessage(channel, message, varptr(messageDescriptions), messageDescriptionCount, receiveOption, readBodyOption, heap, value, valueSize, varptr(index), varptr(asyncContext), error) ; channel : WS_CHANNEL* -> "int" ; message : WS_MESSAGE* -> "int" ; messageDescriptions : WS_MESSAGE_DESCRIPTION** -> "intptr" ; messageDescriptionCount : DWORD -> "int" ; receiveOption : WS_RECEIVE_OPTION -> "int" ; readBodyOption : WS_READ_OPTION -> "int" ; heap : WS_HEAP* optional -> "int" ; value : void* out -> "intptr" ; valueSize : DWORD -> "int" ; index : DWORD* optional, out -> "intptr" ; asyncContext : WS_ASYNC_CONTEXT* optional -> "intptr" ; error : WS_ERROR* optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
webservices = windows.NewLazySystemDLL("webservices.dll")
procWsReceiveMessage = webservices.NewProc("WsReceiveMessage")
)
// channel (WS_CHANNEL*), message (WS_MESSAGE*), messageDescriptions (WS_MESSAGE_DESCRIPTION**), messageDescriptionCount (DWORD), receiveOption (WS_RECEIVE_OPTION), readBodyOption (WS_READ_OPTION), heap (WS_HEAP* optional), value (void* out), valueSize (DWORD), index (DWORD* optional, out), asyncContext (WS_ASYNC_CONTEXT* optional), error (WS_ERROR* optional)
r1, _, err := procWsReceiveMessage.Call(
uintptr(channel),
uintptr(message),
uintptr(messageDescriptions),
uintptr(messageDescriptionCount),
uintptr(receiveOption),
uintptr(readBodyOption),
uintptr(heap),
uintptr(value),
uintptr(valueSize),
uintptr(index),
uintptr(asyncContext),
uintptr(error),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WsReceiveMessage(
channel: Pointer; // WS_CHANNEL*
message: Pointer; // WS_MESSAGE*
messageDescriptions: Pointer; // WS_MESSAGE_DESCRIPTION**
messageDescriptionCount: DWORD; // DWORD
receiveOption: Integer; // WS_RECEIVE_OPTION
readBodyOption: Integer; // WS_READ_OPTION
heap: Pointer; // WS_HEAP* optional
value: Pointer; // void* out
valueSize: DWORD; // DWORD
index: Pointer; // DWORD* optional, out
asyncContext: Pointer; // WS_ASYNC_CONTEXT* optional
error: Pointer // WS_ERROR* optional
): Integer; stdcall;
external 'webservices.dll' name 'WsReceiveMessage';result := DllCall("webservices\WsReceiveMessage"
, "Ptr", channel ; WS_CHANNEL*
, "Ptr", message ; WS_MESSAGE*
, "Ptr", messageDescriptions ; WS_MESSAGE_DESCRIPTION**
, "UInt", messageDescriptionCount ; DWORD
, "Int", receiveOption ; WS_RECEIVE_OPTION
, "Int", readBodyOption ; WS_READ_OPTION
, "Ptr", heap ; WS_HEAP* optional
, "Ptr", value ; void* out
, "UInt", valueSize ; DWORD
, "Ptr", index ; DWORD* optional, out
, "Ptr", asyncContext ; WS_ASYNC_CONTEXT* optional
, "Ptr", error ; WS_ERROR* optional
, "Int") ; return: HRESULT●WsReceiveMessage(channel, message, messageDescriptions, messageDescriptionCount, receiveOption, readBodyOption, heap, value, valueSize, index, asyncContext, error) = DLL("webservices.dll", "int WsReceiveMessage(void*, void*, void*, dword, int, int, void*, void*, dword, void*, void*, void*)")
# 呼び出し: WsReceiveMessage(channel, message, messageDescriptions, messageDescriptionCount, receiveOption, readBodyOption, heap, value, valueSize, index, asyncContext, error)
# channel : WS_CHANNEL* -> "void*"
# message : WS_MESSAGE* -> "void*"
# messageDescriptions : WS_MESSAGE_DESCRIPTION** -> "void*"
# messageDescriptionCount : DWORD -> "dword"
# receiveOption : WS_RECEIVE_OPTION -> "int"
# readBodyOption : WS_READ_OPTION -> "int"
# heap : WS_HEAP* optional -> "void*"
# value : void* out -> "void*"
# valueSize : DWORD -> "dword"
# index : DWORD* optional, out -> "void*"
# asyncContext : WS_ASYNC_CONTEXT* optional -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。