ホーム › Networking.WindowsWebServices › WsRequestReply
WsRequestReply
関数チャネルで要求を送り応答を受信する。
シグネチャ
// webservices.dll
#include <windows.h>
HRESULT WsRequestReply(
WS_CHANNEL* channel,
WS_MESSAGE* requestMessage,
const WS_MESSAGE_DESCRIPTION* requestMessageDescription,
WS_WRITE_OPTION writeOption,
const void* requestBodyValue, // optional
DWORD requestBodyValueSize,
WS_MESSAGE* replyMessage,
const WS_MESSAGE_DESCRIPTION* replyMessageDescription,
WS_READ_OPTION readOption,
WS_HEAP* heap, // optional
void* value, // optional
DWORD valueSize,
const WS_ASYNC_CONTEXT* asyncContext, // optional
WS_ERROR* error // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| channel | WS_CHANNEL* | in | 要求送信と応答受信を行う対象のチャネル。 |
| requestMessage | WS_MESSAGE* | in | 送信する要求メッセージ。 |
| requestMessageDescription | WS_MESSAGE_DESCRIPTION* | in | 要求メッセージのアクションと本文型を記述する。 |
| writeOption | WS_WRITE_OPTION | in | 要求本文の書き込み方法を示す列挙値。 |
| requestBodyValue | void* | inoptional | 送信する要求本文データへのポインタ。NULL可。 |
| requestBodyValueSize | DWORD | in | requestBodyValueのバイトサイズ。 |
| replyMessage | WS_MESSAGE* | in | 応答受信に使用するメッセージ。 |
| replyMessageDescription | WS_MESSAGE_DESCRIPTION* | in | 応答メッセージのアクションと本文型を記述する。 |
| readOption | WS_READ_OPTION | in | 応答本文の読み取り方法を示す列挙値。 |
| heap | WS_HEAP* | inoptional | 応答本文のデシリアライズ確保に使うWS_HEAPヒープ。 |
| value | void* | outoptional | デシリアライズした応答本文を格納する出力バッファ。 |
| valueSize | DWORD | in | valueバッファのバイトサイズ。 |
| asyncContext | WS_ASYNC_CONTEXT* | inoptional | 非同期実行のためのコンテキスト。同期実行ならNULL。 |
| error | WS_ERROR* | inoptional | 失敗時の追加エラー情報を格納するWS_ERRORオブジェクト。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// webservices.dll
#include <windows.h>
HRESULT WsRequestReply(
WS_CHANNEL* channel,
WS_MESSAGE* requestMessage,
const WS_MESSAGE_DESCRIPTION* requestMessageDescription,
WS_WRITE_OPTION writeOption,
const void* requestBodyValue, // optional
DWORD requestBodyValueSize,
WS_MESSAGE* replyMessage,
const WS_MESSAGE_DESCRIPTION* replyMessageDescription,
WS_READ_OPTION readOption,
WS_HEAP* heap, // optional
void* value, // optional
DWORD valueSize,
const WS_ASYNC_CONTEXT* asyncContext, // optional
WS_ERROR* error // optional
);[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsRequestReply(
ref IntPtr channel, // WS_CHANNEL*
ref IntPtr requestMessage, // WS_MESSAGE*
IntPtr requestMessageDescription, // WS_MESSAGE_DESCRIPTION*
int writeOption, // WS_WRITE_OPTION
IntPtr requestBodyValue, // void* optional
uint requestBodyValueSize, // DWORD
ref IntPtr replyMessage, // WS_MESSAGE*
IntPtr replyMessageDescription, // WS_MESSAGE_DESCRIPTION*
int readOption, // WS_READ_OPTION
IntPtr heap, // WS_HEAP* optional
IntPtr value, // void* optional, out
uint valueSize, // DWORD
IntPtr asyncContext, // WS_ASYNC_CONTEXT* optional
IntPtr error // WS_ERROR* optional
);<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsRequestReply(
ByRef channel As IntPtr, ' WS_CHANNEL*
ByRef requestMessage As IntPtr, ' WS_MESSAGE*
requestMessageDescription As IntPtr, ' WS_MESSAGE_DESCRIPTION*
writeOption As Integer, ' WS_WRITE_OPTION
requestBodyValue As IntPtr, ' void* optional
requestBodyValueSize As UInteger, ' DWORD
ByRef replyMessage As IntPtr, ' WS_MESSAGE*
replyMessageDescription As IntPtr, ' WS_MESSAGE_DESCRIPTION*
readOption As Integer, ' WS_READ_OPTION
heap As IntPtr, ' WS_HEAP* optional
value As IntPtr, ' void* optional, out
valueSize As UInteger, ' DWORD
asyncContext As IntPtr, ' WS_ASYNC_CONTEXT* optional
[error] As IntPtr ' WS_ERROR* optional
) As Integer
End Function' channel : WS_CHANNEL*
' requestMessage : WS_MESSAGE*
' requestMessageDescription : WS_MESSAGE_DESCRIPTION*
' writeOption : WS_WRITE_OPTION
' requestBodyValue : void* optional
' requestBodyValueSize : DWORD
' replyMessage : WS_MESSAGE*
' replyMessageDescription : WS_MESSAGE_DESCRIPTION*
' readOption : WS_READ_OPTION
' heap : WS_HEAP* optional
' value : void* optional, out
' valueSize : DWORD
' asyncContext : WS_ASYNC_CONTEXT* optional
' error : WS_ERROR* optional
Declare PtrSafe Function WsRequestReply Lib "webservices" ( _
ByRef channel As LongPtr, _
ByRef requestMessage As LongPtr, _
ByVal requestMessageDescription As LongPtr, _
ByVal writeOption As Long, _
ByVal requestBodyValue As LongPtr, _
ByVal requestBodyValueSize As Long, _
ByRef replyMessage As LongPtr, _
ByVal replyMessageDescription As LongPtr, _
ByVal readOption As Long, _
ByVal heap As LongPtr, _
ByVal value As LongPtr, _
ByVal valueSize As Long, _
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
WsRequestReply = ctypes.windll.webservices.WsRequestReply
WsRequestReply.restype = ctypes.c_int
WsRequestReply.argtypes = [
ctypes.c_void_p, # channel : WS_CHANNEL*
ctypes.c_void_p, # requestMessage : WS_MESSAGE*
ctypes.c_void_p, # requestMessageDescription : WS_MESSAGE_DESCRIPTION*
ctypes.c_int, # writeOption : WS_WRITE_OPTION
ctypes.POINTER(None), # requestBodyValue : void* optional
wintypes.DWORD, # requestBodyValueSize : DWORD
ctypes.c_void_p, # replyMessage : WS_MESSAGE*
ctypes.c_void_p, # replyMessageDescription : WS_MESSAGE_DESCRIPTION*
ctypes.c_int, # readOption : WS_READ_OPTION
ctypes.c_void_p, # heap : WS_HEAP* optional
ctypes.POINTER(None), # value : void* optional, out
wintypes.DWORD, # valueSize : DWORD
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')
WsRequestReply = Fiddle::Function.new(
lib['WsRequestReply'],
[
Fiddle::TYPE_VOIDP, # channel : WS_CHANNEL*
Fiddle::TYPE_VOIDP, # requestMessage : WS_MESSAGE*
Fiddle::TYPE_VOIDP, # requestMessageDescription : WS_MESSAGE_DESCRIPTION*
Fiddle::TYPE_INT, # writeOption : WS_WRITE_OPTION
Fiddle::TYPE_VOIDP, # requestBodyValue : void* optional
-Fiddle::TYPE_INT, # requestBodyValueSize : DWORD
Fiddle::TYPE_VOIDP, # replyMessage : WS_MESSAGE*
Fiddle::TYPE_VOIDP, # replyMessageDescription : WS_MESSAGE_DESCRIPTION*
Fiddle::TYPE_INT, # readOption : WS_READ_OPTION
Fiddle::TYPE_VOIDP, # heap : WS_HEAP* optional
Fiddle::TYPE_VOIDP, # value : void* optional, out
-Fiddle::TYPE_INT, # valueSize : DWORD
Fiddle::TYPE_VOIDP, # asyncContext : WS_ASYNC_CONTEXT* optional
Fiddle::TYPE_VOIDP, # error : WS_ERROR* optional
],
Fiddle::TYPE_INT)#[link(name = "webservices")]
extern "system" {
fn WsRequestReply(
channel: *mut isize, // WS_CHANNEL*
requestMessage: *mut isize, // WS_MESSAGE*
requestMessageDescription: *const WS_MESSAGE_DESCRIPTION, // WS_MESSAGE_DESCRIPTION*
writeOption: i32, // WS_WRITE_OPTION
requestBodyValue: *const (), // void* optional
requestBodyValueSize: u32, // DWORD
replyMessage: *mut isize, // WS_MESSAGE*
replyMessageDescription: *const WS_MESSAGE_DESCRIPTION, // WS_MESSAGE_DESCRIPTION*
readOption: i32, // WS_READ_OPTION
heap: *mut isize, // WS_HEAP* optional
value: *mut (), // void* optional, out
valueSize: u32, // DWORD
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 WsRequestReply(ref IntPtr channel, ref IntPtr requestMessage, IntPtr requestMessageDescription, int writeOption, IntPtr requestBodyValue, uint requestBodyValueSize, ref IntPtr replyMessage, IntPtr replyMessageDescription, int readOption, IntPtr heap, IntPtr value, uint valueSize, IntPtr asyncContext, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsRequestReply' -Namespace Win32 -PassThru
# $api::WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error)#uselib "webservices.dll"
#func global WsRequestReply "WsRequestReply" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WsRequestReply varptr(channel), varptr(requestMessage), varptr(requestMessageDescription), writeOption, requestBodyValue, requestBodyValueSize, varptr(replyMessage), varptr(replyMessageDescription), readOption, varptr(heap), value, valueSize, varptr(asyncContext), varptr(error) ; 戻り値は stat
; channel : WS_CHANNEL* -> "sptr"
; requestMessage : WS_MESSAGE* -> "sptr"
; requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> "sptr"
; writeOption : WS_WRITE_OPTION -> "sptr"
; requestBodyValue : void* optional -> "sptr"
; requestBodyValueSize : DWORD -> "sptr"
; replyMessage : WS_MESSAGE* -> "sptr"
; replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> "sptr"
; readOption : WS_READ_OPTION -> "sptr"
; heap : WS_HEAP* optional -> "sptr"
; value : void* optional, out -> "sptr"
; valueSize : DWORD -> "sptr"
; asyncContext : WS_ASYNC_CONTEXT* optional -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "webservices.dll" #cfunc global WsRequestReply "WsRequestReply" var, var, var, int, sptr, int, var, var, int, var, sptr, int, var, var ; res = WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error) ; channel : WS_CHANNEL* -> "var" ; requestMessage : WS_MESSAGE* -> "var" ; requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> "var" ; writeOption : WS_WRITE_OPTION -> "int" ; requestBodyValue : void* optional -> "sptr" ; requestBodyValueSize : DWORD -> "int" ; replyMessage : WS_MESSAGE* -> "var" ; replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> "var" ; readOption : WS_READ_OPTION -> "int" ; heap : WS_HEAP* optional -> "var" ; value : void* optional, out -> "sptr" ; valueSize : DWORD -> "int" ; asyncContext : WS_ASYNC_CONTEXT* optional -> "var" ; error : WS_ERROR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "webservices.dll" #cfunc global WsRequestReply "WsRequestReply" sptr, sptr, sptr, int, sptr, int, sptr, sptr, int, sptr, sptr, int, sptr, sptr ; res = WsRequestReply(varptr(channel), varptr(requestMessage), varptr(requestMessageDescription), writeOption, requestBodyValue, requestBodyValueSize, varptr(replyMessage), varptr(replyMessageDescription), readOption, varptr(heap), value, valueSize, varptr(asyncContext), varptr(error)) ; channel : WS_CHANNEL* -> "sptr" ; requestMessage : WS_MESSAGE* -> "sptr" ; requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> "sptr" ; writeOption : WS_WRITE_OPTION -> "int" ; requestBodyValue : void* optional -> "sptr" ; requestBodyValueSize : DWORD -> "int" ; replyMessage : WS_MESSAGE* -> "sptr" ; replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> "sptr" ; readOption : WS_READ_OPTION -> "int" ; heap : WS_HEAP* optional -> "sptr" ; value : void* optional, out -> "sptr" ; valueSize : DWORD -> "int" ; asyncContext : WS_ASYNC_CONTEXT* optional -> "sptr" ; error : WS_ERROR* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WsRequestReply(WS_CHANNEL* channel, WS_MESSAGE* requestMessage, WS_MESSAGE_DESCRIPTION* requestMessageDescription, WS_WRITE_OPTION writeOption, void* requestBodyValue, DWORD requestBodyValueSize, WS_MESSAGE* replyMessage, WS_MESSAGE_DESCRIPTION* replyMessageDescription, WS_READ_OPTION readOption, WS_HEAP* heap, void* value, DWORD valueSize, WS_ASYNC_CONTEXT* asyncContext, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsRequestReply "WsRequestReply" var, var, var, int, intptr, int, var, var, int, var, intptr, int, var, var ; res = WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error) ; channel : WS_CHANNEL* -> "var" ; requestMessage : WS_MESSAGE* -> "var" ; requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> "var" ; writeOption : WS_WRITE_OPTION -> "int" ; requestBodyValue : void* optional -> "intptr" ; requestBodyValueSize : DWORD -> "int" ; replyMessage : WS_MESSAGE* -> "var" ; replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> "var" ; readOption : WS_READ_OPTION -> "int" ; heap : WS_HEAP* optional -> "var" ; value : void* optional, out -> "intptr" ; valueSize : DWORD -> "int" ; asyncContext : WS_ASYNC_CONTEXT* optional -> "var" ; error : WS_ERROR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WsRequestReply(WS_CHANNEL* channel, WS_MESSAGE* requestMessage, WS_MESSAGE_DESCRIPTION* requestMessageDescription, WS_WRITE_OPTION writeOption, void* requestBodyValue, DWORD requestBodyValueSize, WS_MESSAGE* replyMessage, WS_MESSAGE_DESCRIPTION* replyMessageDescription, WS_READ_OPTION readOption, WS_HEAP* heap, void* value, DWORD valueSize, WS_ASYNC_CONTEXT* asyncContext, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsRequestReply "WsRequestReply" intptr, intptr, intptr, int, intptr, int, intptr, intptr, int, intptr, intptr, int, intptr, intptr ; res = WsRequestReply(varptr(channel), varptr(requestMessage), varptr(requestMessageDescription), writeOption, requestBodyValue, requestBodyValueSize, varptr(replyMessage), varptr(replyMessageDescription), readOption, varptr(heap), value, valueSize, varptr(asyncContext), varptr(error)) ; channel : WS_CHANNEL* -> "intptr" ; requestMessage : WS_MESSAGE* -> "intptr" ; requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> "intptr" ; writeOption : WS_WRITE_OPTION -> "int" ; requestBodyValue : void* optional -> "intptr" ; requestBodyValueSize : DWORD -> "int" ; replyMessage : WS_MESSAGE* -> "intptr" ; replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> "intptr" ; readOption : WS_READ_OPTION -> "int" ; heap : WS_HEAP* optional -> "intptr" ; value : void* optional, out -> "intptr" ; valueSize : DWORD -> "int" ; asyncContext : WS_ASYNC_CONTEXT* optional -> "intptr" ; error : WS_ERROR* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
webservices = windows.NewLazySystemDLL("webservices.dll")
procWsRequestReply = webservices.NewProc("WsRequestReply")
)
// channel (WS_CHANNEL*), requestMessage (WS_MESSAGE*), requestMessageDescription (WS_MESSAGE_DESCRIPTION*), writeOption (WS_WRITE_OPTION), requestBodyValue (void* optional), requestBodyValueSize (DWORD), replyMessage (WS_MESSAGE*), replyMessageDescription (WS_MESSAGE_DESCRIPTION*), readOption (WS_READ_OPTION), heap (WS_HEAP* optional), value (void* optional, out), valueSize (DWORD), asyncContext (WS_ASYNC_CONTEXT* optional), error (WS_ERROR* optional)
r1, _, err := procWsRequestReply.Call(
uintptr(channel),
uintptr(requestMessage),
uintptr(requestMessageDescription),
uintptr(writeOption),
uintptr(requestBodyValue),
uintptr(requestBodyValueSize),
uintptr(replyMessage),
uintptr(replyMessageDescription),
uintptr(readOption),
uintptr(heap),
uintptr(value),
uintptr(valueSize),
uintptr(asyncContext),
uintptr(error),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WsRequestReply(
channel: Pointer; // WS_CHANNEL*
requestMessage: Pointer; // WS_MESSAGE*
requestMessageDescription: Pointer; // WS_MESSAGE_DESCRIPTION*
writeOption: Integer; // WS_WRITE_OPTION
requestBodyValue: Pointer; // void* optional
requestBodyValueSize: DWORD; // DWORD
replyMessage: Pointer; // WS_MESSAGE*
replyMessageDescription: Pointer; // WS_MESSAGE_DESCRIPTION*
readOption: Integer; // WS_READ_OPTION
heap: Pointer; // WS_HEAP* optional
value: Pointer; // void* optional, out
valueSize: DWORD; // DWORD
asyncContext: Pointer; // WS_ASYNC_CONTEXT* optional
error: Pointer // WS_ERROR* optional
): Integer; stdcall;
external 'webservices.dll' name 'WsRequestReply';result := DllCall("webservices\WsRequestReply"
, "Ptr", channel ; WS_CHANNEL*
, "Ptr", requestMessage ; WS_MESSAGE*
, "Ptr", requestMessageDescription ; WS_MESSAGE_DESCRIPTION*
, "Int", writeOption ; WS_WRITE_OPTION
, "Ptr", requestBodyValue ; void* optional
, "UInt", requestBodyValueSize ; DWORD
, "Ptr", replyMessage ; WS_MESSAGE*
, "Ptr", replyMessageDescription ; WS_MESSAGE_DESCRIPTION*
, "Int", readOption ; WS_READ_OPTION
, "Ptr", heap ; WS_HEAP* optional
, "Ptr", value ; void* optional, out
, "UInt", valueSize ; DWORD
, "Ptr", asyncContext ; WS_ASYNC_CONTEXT* optional
, "Ptr", error ; WS_ERROR* optional
, "Int") ; return: HRESULT●WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error) = DLL("webservices.dll", "int WsRequestReply(void*, void*, void*, int, void*, dword, void*, void*, int, void*, void*, dword, void*, void*)")
# 呼び出し: WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error)
# channel : WS_CHANNEL* -> "void*"
# requestMessage : WS_MESSAGE* -> "void*"
# requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> "void*"
# writeOption : WS_WRITE_OPTION -> "int"
# requestBodyValue : void* optional -> "void*"
# requestBodyValueSize : DWORD -> "dword"
# replyMessage : WS_MESSAGE* -> "void*"
# replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> "void*"
# readOption : WS_READ_OPTION -> "int"
# heap : WS_HEAP* optional -> "void*"
# value : void* optional, out -> "void*"
# valueSize : DWORD -> "dword"
# asyncContext : WS_ASYNC_CONTEXT* optional -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "webservices" fn WsRequestReply(
channel: [*c]isize, // WS_CHANNEL*
requestMessage: [*c]isize, // WS_MESSAGE*
requestMessageDescription: [*c]WS_MESSAGE_DESCRIPTION, // WS_MESSAGE_DESCRIPTION*
writeOption: i32, // WS_WRITE_OPTION
requestBodyValue: ?*anyopaque, // void* optional
requestBodyValueSize: u32, // DWORD
replyMessage: [*c]isize, // WS_MESSAGE*
replyMessageDescription: [*c]WS_MESSAGE_DESCRIPTION, // WS_MESSAGE_DESCRIPTION*
readOption: i32, // WS_READ_OPTION
heap: [*c]isize, // WS_HEAP* optional
value: ?*anyopaque, // void* optional, out
valueSize: u32, // DWORD
asyncContext: [*c]WS_ASYNC_CONTEXT, // WS_ASYNC_CONTEXT* optional
error: [*c]isize // WS_ERROR* optional
) callconv(std.os.windows.WINAPI) i32;proc WsRequestReply(
channel: ptr int, # WS_CHANNEL*
requestMessage: ptr int, # WS_MESSAGE*
requestMessageDescription: ptr WS_MESSAGE_DESCRIPTION, # WS_MESSAGE_DESCRIPTION*
writeOption: int32, # WS_WRITE_OPTION
requestBodyValue: pointer, # void* optional
requestBodyValueSize: uint32, # DWORD
replyMessage: ptr int, # WS_MESSAGE*
replyMessageDescription: ptr WS_MESSAGE_DESCRIPTION, # WS_MESSAGE_DESCRIPTION*
readOption: int32, # WS_READ_OPTION
heap: ptr int, # WS_HEAP* optional
value: pointer, # void* optional, out
valueSize: uint32, # DWORD
asyncContext: ptr WS_ASYNC_CONTEXT, # WS_ASYNC_CONTEXT* optional
error: ptr int # WS_ERROR* optional
): int32 {.importc: "WsRequestReply", stdcall, dynlib: "webservices.dll".}pragma(lib, "webservices");
extern(Windows)
int WsRequestReply(
ptrdiff_t* channel, // WS_CHANNEL*
ptrdiff_t* requestMessage, // WS_MESSAGE*
WS_MESSAGE_DESCRIPTION* requestMessageDescription, // WS_MESSAGE_DESCRIPTION*
int writeOption, // WS_WRITE_OPTION
void* requestBodyValue, // void* optional
uint requestBodyValueSize, // DWORD
ptrdiff_t* replyMessage, // WS_MESSAGE*
WS_MESSAGE_DESCRIPTION* replyMessageDescription, // WS_MESSAGE_DESCRIPTION*
int readOption, // WS_READ_OPTION
ptrdiff_t* heap, // WS_HEAP* optional
void* value, // void* optional, out
uint valueSize, // DWORD
WS_ASYNC_CONTEXT* asyncContext, // WS_ASYNC_CONTEXT* optional
ptrdiff_t* error // WS_ERROR* optional
);ccall((:WsRequestReply, "webservices.dll"), stdcall, Int32,
(Ptr{Int}, Ptr{Int}, Ptr{WS_MESSAGE_DESCRIPTION}, Int32, Ptr{Cvoid}, UInt32, Ptr{Int}, Ptr{WS_MESSAGE_DESCRIPTION}, Int32, Ptr{Int}, Ptr{Cvoid}, UInt32, Ptr{WS_ASYNC_CONTEXT}, Ptr{Int}),
channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error)
# channel : WS_CHANNEL* -> Ptr{Int}
# requestMessage : WS_MESSAGE* -> Ptr{Int}
# requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> Ptr{WS_MESSAGE_DESCRIPTION}
# writeOption : WS_WRITE_OPTION -> Int32
# requestBodyValue : void* optional -> Ptr{Cvoid}
# requestBodyValueSize : DWORD -> UInt32
# replyMessage : WS_MESSAGE* -> Ptr{Int}
# replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> Ptr{WS_MESSAGE_DESCRIPTION}
# readOption : WS_READ_OPTION -> Int32
# heap : WS_HEAP* optional -> Ptr{Int}
# value : void* optional, out -> Ptr{Cvoid}
# valueSize : DWORD -> UInt32
# asyncContext : WS_ASYNC_CONTEXT* optional -> Ptr{WS_ASYNC_CONTEXT}
# error : WS_ERROR* optional -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WsRequestReply(
intptr_t* channel,
intptr_t* requestMessage,
void* requestMessageDescription,
int32_t writeOption,
void* requestBodyValue,
uint32_t requestBodyValueSize,
intptr_t* replyMessage,
void* replyMessageDescription,
int32_t readOption,
intptr_t* heap,
void* value,
uint32_t valueSize,
void* asyncContext,
intptr_t* error);
]]
local webservices = ffi.load("webservices")
-- webservices.WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error)
-- channel : WS_CHANNEL*
-- requestMessage : WS_MESSAGE*
-- requestMessageDescription : WS_MESSAGE_DESCRIPTION*
-- writeOption : WS_WRITE_OPTION
-- requestBodyValue : void* optional
-- requestBodyValueSize : DWORD
-- replyMessage : WS_MESSAGE*
-- replyMessageDescription : WS_MESSAGE_DESCRIPTION*
-- readOption : WS_READ_OPTION
-- heap : WS_HEAP* optional
-- value : void* optional, out
-- valueSize : DWORD
-- asyncContext : WS_ASYNC_CONTEXT* optional
-- error : WS_ERROR* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('webservices.dll');
const WsRequestReply = lib.func('__stdcall', 'WsRequestReply', 'int32_t', ['intptr_t *', 'intptr_t *', 'void *', 'int32_t', 'void *', 'uint32_t', 'intptr_t *', 'void *', 'int32_t', 'intptr_t *', 'void *', 'uint32_t', 'void *', 'intptr_t *']);
// WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error)
// channel : WS_CHANNEL* -> 'intptr_t *'
// requestMessage : WS_MESSAGE* -> 'intptr_t *'
// requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> 'void *'
// writeOption : WS_WRITE_OPTION -> 'int32_t'
// requestBodyValue : void* optional -> 'void *'
// requestBodyValueSize : DWORD -> 'uint32_t'
// replyMessage : WS_MESSAGE* -> 'intptr_t *'
// replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> 'void *'
// readOption : WS_READ_OPTION -> 'int32_t'
// heap : WS_HEAP* optional -> 'intptr_t *'
// value : void* optional, out -> 'void *'
// valueSize : DWORD -> 'uint32_t'
// asyncContext : WS_ASYNC_CONTEXT* optional -> 'void *'
// error : WS_ERROR* optional -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("webservices.dll", {
WsRequestReply: { parameters: ["pointer", "pointer", "pointer", "i32", "pointer", "u32", "pointer", "pointer", "i32", "pointer", "pointer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error)
// channel : WS_CHANNEL* -> "pointer"
// requestMessage : WS_MESSAGE* -> "pointer"
// requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> "pointer"
// writeOption : WS_WRITE_OPTION -> "i32"
// requestBodyValue : void* optional -> "pointer"
// requestBodyValueSize : DWORD -> "u32"
// replyMessage : WS_MESSAGE* -> "pointer"
// replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> "pointer"
// readOption : WS_READ_OPTION -> "i32"
// heap : WS_HEAP* optional -> "pointer"
// value : void* optional, out -> "pointer"
// valueSize : DWORD -> "u32"
// asyncContext : WS_ASYNC_CONTEXT* optional -> "pointer"
// error : WS_ERROR* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WsRequestReply(
intptr_t* channel,
intptr_t* requestMessage,
void* requestMessageDescription,
int32_t writeOption,
void* requestBodyValue,
uint32_t requestBodyValueSize,
intptr_t* replyMessage,
void* replyMessageDescription,
int32_t readOption,
intptr_t* heap,
void* value,
uint32_t valueSize,
void* asyncContext,
intptr_t* error);
C, "webservices.dll");
// $ffi->WsRequestReply(channel, requestMessage, requestMessageDescription, writeOption, requestBodyValue, requestBodyValueSize, replyMessage, replyMessageDescription, readOption, heap, value, valueSize, asyncContext, error);
// channel : WS_CHANNEL*
// requestMessage : WS_MESSAGE*
// requestMessageDescription : WS_MESSAGE_DESCRIPTION*
// writeOption : WS_WRITE_OPTION
// requestBodyValue : void* optional
// requestBodyValueSize : DWORD
// replyMessage : WS_MESSAGE*
// replyMessageDescription : WS_MESSAGE_DESCRIPTION*
// readOption : WS_READ_OPTION
// heap : WS_HEAP* optional
// value : void* optional, out
// valueSize : DWORD
// asyncContext : WS_ASYNC_CONTEXT* optional
// error : WS_ERROR* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Webservices extends StdCallLibrary {
Webservices INSTANCE = Native.load("webservices", Webservices.class);
int WsRequestReply(
LongByReference channel, // WS_CHANNEL*
LongByReference requestMessage, // WS_MESSAGE*
Pointer requestMessageDescription, // WS_MESSAGE_DESCRIPTION*
int writeOption, // WS_WRITE_OPTION
Pointer requestBodyValue, // void* optional
int requestBodyValueSize, // DWORD
LongByReference replyMessage, // WS_MESSAGE*
Pointer replyMessageDescription, // WS_MESSAGE_DESCRIPTION*
int readOption, // WS_READ_OPTION
LongByReference heap, // WS_HEAP* optional
Pointer value, // void* optional, out
int valueSize, // DWORD
Pointer asyncContext, // WS_ASYNC_CONTEXT* optional
LongByReference error // WS_ERROR* optional
);
}@[Link("webservices")]
lib Libwebservices
fun WsRequestReply = WsRequestReply(
channel : LibC::SSizeT*, # WS_CHANNEL*
requestMessage : LibC::SSizeT*, # WS_MESSAGE*
requestMessageDescription : WS_MESSAGE_DESCRIPTION*, # WS_MESSAGE_DESCRIPTION*
writeOption : Int32, # WS_WRITE_OPTION
requestBodyValue : Void*, # void* optional
requestBodyValueSize : UInt32, # DWORD
replyMessage : LibC::SSizeT*, # WS_MESSAGE*
replyMessageDescription : WS_MESSAGE_DESCRIPTION*, # WS_MESSAGE_DESCRIPTION*
readOption : Int32, # WS_READ_OPTION
heap : LibC::SSizeT*, # WS_HEAP* optional
value : Void*, # void* optional, out
valueSize : UInt32, # DWORD
asyncContext : WS_ASYNC_CONTEXT*, # WS_ASYNC_CONTEXT* optional
error : LibC::SSizeT* # WS_ERROR* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WsRequestReplyNative = Int32 Function(Pointer<IntPtr>, Pointer<IntPtr>, Pointer<Void>, Int32, Pointer<Void>, Uint32, Pointer<IntPtr>, Pointer<Void>, Int32, Pointer<IntPtr>, Pointer<Void>, Uint32, Pointer<Void>, Pointer<IntPtr>);
typedef WsRequestReplyDart = int Function(Pointer<IntPtr>, Pointer<IntPtr>, Pointer<Void>, int, Pointer<Void>, int, Pointer<IntPtr>, Pointer<Void>, int, Pointer<IntPtr>, Pointer<Void>, int, Pointer<Void>, Pointer<IntPtr>);
final WsRequestReply = DynamicLibrary.open('webservices.dll')
.lookupFunction<WsRequestReplyNative, WsRequestReplyDart>('WsRequestReply');
// channel : WS_CHANNEL* -> Pointer<IntPtr>
// requestMessage : WS_MESSAGE* -> Pointer<IntPtr>
// requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> Pointer<Void>
// writeOption : WS_WRITE_OPTION -> Int32
// requestBodyValue : void* optional -> Pointer<Void>
// requestBodyValueSize : DWORD -> Uint32
// replyMessage : WS_MESSAGE* -> Pointer<IntPtr>
// replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> Pointer<Void>
// readOption : WS_READ_OPTION -> Int32
// heap : WS_HEAP* optional -> Pointer<IntPtr>
// value : void* optional, out -> Pointer<Void>
// valueSize : DWORD -> Uint32
// asyncContext : WS_ASYNC_CONTEXT* optional -> Pointer<Void>
// error : WS_ERROR* optional -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WsRequestReply(
channel: Pointer; // WS_CHANNEL*
requestMessage: Pointer; // WS_MESSAGE*
requestMessageDescription: Pointer; // WS_MESSAGE_DESCRIPTION*
writeOption: Integer; // WS_WRITE_OPTION
requestBodyValue: Pointer; // void* optional
requestBodyValueSize: DWORD; // DWORD
replyMessage: Pointer; // WS_MESSAGE*
replyMessageDescription: Pointer; // WS_MESSAGE_DESCRIPTION*
readOption: Integer; // WS_READ_OPTION
heap: Pointer; // WS_HEAP* optional
value: Pointer; // void* optional, out
valueSize: DWORD; // DWORD
asyncContext: Pointer; // WS_ASYNC_CONTEXT* optional
error: Pointer // WS_ERROR* optional
): Integer; stdcall;
external 'webservices.dll' name 'WsRequestReply';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WsRequestReply"
c_WsRequestReply :: Ptr CIntPtr -> Ptr CIntPtr -> Ptr () -> Int32 -> Ptr () -> Word32 -> Ptr CIntPtr -> Ptr () -> Int32 -> Ptr CIntPtr -> Ptr () -> Word32 -> Ptr () -> Ptr CIntPtr -> IO Int32
-- channel : WS_CHANNEL* -> Ptr CIntPtr
-- requestMessage : WS_MESSAGE* -> Ptr CIntPtr
-- requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> Ptr ()
-- writeOption : WS_WRITE_OPTION -> Int32
-- requestBodyValue : void* optional -> Ptr ()
-- requestBodyValueSize : DWORD -> Word32
-- replyMessage : WS_MESSAGE* -> Ptr CIntPtr
-- replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> Ptr ()
-- readOption : WS_READ_OPTION -> Int32
-- heap : WS_HEAP* optional -> Ptr CIntPtr
-- value : void* optional, out -> Ptr ()
-- valueSize : DWORD -> Word32
-- asyncContext : WS_ASYNC_CONTEXT* optional -> Ptr ()
-- error : WS_ERROR* optional -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsrequestreply =
foreign "WsRequestReply"
((ptr intptr_t) @-> (ptr intptr_t) @-> (ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> (ptr intptr_t) @-> (ptr void) @-> int32_t @-> (ptr intptr_t) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> (ptr intptr_t) @-> returning int32_t)
(* channel : WS_CHANNEL* -> (ptr intptr_t) *)
(* requestMessage : WS_MESSAGE* -> (ptr intptr_t) *)
(* requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> (ptr void) *)
(* writeOption : WS_WRITE_OPTION -> int32_t *)
(* requestBodyValue : void* optional -> (ptr void) *)
(* requestBodyValueSize : DWORD -> uint32_t *)
(* replyMessage : WS_MESSAGE* -> (ptr intptr_t) *)
(* replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> (ptr void) *)
(* readOption : WS_READ_OPTION -> int32_t *)
(* heap : WS_HEAP* optional -> (ptr intptr_t) *)
(* value : void* optional, out -> (ptr void) *)
(* valueSize : DWORD -> uint32_t *)
(* asyncContext : WS_ASYNC_CONTEXT* optional -> (ptr void) *)
(* error : WS_ERROR* optional -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library webservices (t "webservices.dll"))
(cffi:use-foreign-library webservices)
(cffi:defcfun ("WsRequestReply" ws-request-reply :convention :stdcall) :int32
(channel :pointer) ; WS_CHANNEL*
(request-message :pointer) ; WS_MESSAGE*
(request-message-description :pointer) ; WS_MESSAGE_DESCRIPTION*
(write-option :int32) ; WS_WRITE_OPTION
(request-body-value :pointer) ; void* optional
(request-body-value-size :uint32) ; DWORD
(reply-message :pointer) ; WS_MESSAGE*
(reply-message-description :pointer) ; WS_MESSAGE_DESCRIPTION*
(read-option :int32) ; WS_READ_OPTION
(heap :pointer) ; WS_HEAP* optional
(value :pointer) ; void* optional, out
(value-size :uint32) ; DWORD
(async-context :pointer) ; WS_ASYNC_CONTEXT* optional
(error :pointer)) ; WS_ERROR* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WsRequestReply = Win32::API::More->new('webservices',
'int WsRequestReply(LPVOID channel, LPVOID requestMessage, LPVOID requestMessageDescription, int writeOption, LPVOID requestBodyValue, DWORD requestBodyValueSize, LPVOID replyMessage, LPVOID replyMessageDescription, int readOption, LPVOID heap, LPVOID value, DWORD valueSize, LPVOID asyncContext, LPVOID error)');
# my $ret = $WsRequestReply->Call($channel, $requestMessage, $requestMessageDescription, $writeOption, $requestBodyValue, $requestBodyValueSize, $replyMessage, $replyMessageDescription, $readOption, $heap, $value, $valueSize, $asyncContext, $error);
# channel : WS_CHANNEL* -> LPVOID
# requestMessage : WS_MESSAGE* -> LPVOID
# requestMessageDescription : WS_MESSAGE_DESCRIPTION* -> LPVOID
# writeOption : WS_WRITE_OPTION -> int
# requestBodyValue : void* optional -> LPVOID
# requestBodyValueSize : DWORD -> DWORD
# replyMessage : WS_MESSAGE* -> LPVOID
# replyMessageDescription : WS_MESSAGE_DESCRIPTION* -> LPVOID
# readOption : WS_READ_OPTION -> int
# heap : WS_HEAP* optional -> LPVOID
# value : void* optional, out -> LPVOID
# valueSize : DWORD -> DWORD
# asyncContext : WS_ASYNC_CONTEXT* optional -> LPVOID
# error : WS_ERROR* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。