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

WsPushBytes

関数
コールバック経由でXMLにバイト列をプッシュ書き込みする。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WsPushBytes(
    WS_XML_WRITER* writer,
    WS_PUSH_BYTES_CALLBACK callback,
    void* callbackState,   // optional
    WS_ERROR* error   // optional
);

パラメーター

名前方向
writerWS_XML_WRITER*in
callbackWS_PUSH_BYTES_CALLBACKin
callbackStatevoid*inoptional
errorWS_ERROR*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsPushBytes(
    WS_XML_WRITER* writer,
    WS_PUSH_BYTES_CALLBACK callback,
    void* callbackState,   // optional
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsPushBytes(
    ref IntPtr writer,   // WS_XML_WRITER*
    IntPtr callback,   // WS_PUSH_BYTES_CALLBACK
    IntPtr callbackState,   // void* optional
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsPushBytes(
    ByRef writer As IntPtr,   ' WS_XML_WRITER*
    callback As IntPtr,   ' WS_PUSH_BYTES_CALLBACK
    callbackState As IntPtr,   ' void* optional
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' writer : WS_XML_WRITER*
' callback : WS_PUSH_BYTES_CALLBACK
' callbackState : void* optional
' error : WS_ERROR* optional
Declare PtrSafe Function WsPushBytes Lib "webservices" ( _
    ByRef writer As LongPtr, _
    ByVal callback As LongPtr, _
    ByVal callbackState 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

WsPushBytes = ctypes.windll.webservices.WsPushBytes
WsPushBytes.restype = ctypes.c_int
WsPushBytes.argtypes = [
    ctypes.c_void_p,  # writer : WS_XML_WRITER*
    ctypes.c_void_p,  # callback : WS_PUSH_BYTES_CALLBACK
    ctypes.POINTER(None),  # callbackState : void* optional
    ctypes.c_void_p,  # error : WS_ERROR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webservices.dll')
WsPushBytes = Fiddle::Function.new(
  lib['WsPushBytes'],
  [
    Fiddle::TYPE_VOIDP,  # writer : WS_XML_WRITER*
    Fiddle::TYPE_VOIDP,  # callback : WS_PUSH_BYTES_CALLBACK
    Fiddle::TYPE_VOIDP,  # callbackState : void* optional
    Fiddle::TYPE_VOIDP,  # error : WS_ERROR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "webservices")]
extern "system" {
    fn WsPushBytes(
        writer: *mut isize,  // WS_XML_WRITER*
        callback: *const core::ffi::c_void,  // WS_PUSH_BYTES_CALLBACK
        callbackState: *mut (),  // void* 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 WsPushBytes(ref IntPtr writer, IntPtr callback, IntPtr callbackState, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsPushBytes' -Namespace Win32 -PassThru
# $api::WsPushBytes(writer, callback, callbackState, error)
#uselib "webservices.dll"
#func global WsPushBytes "WsPushBytes" sptr, sptr, sptr, sptr
; WsPushBytes writer, callback, callbackState, error   ; 戻り値は stat
; writer : WS_XML_WRITER* -> "sptr"
; callback : WS_PUSH_BYTES_CALLBACK -> "sptr"
; callbackState : void* optional -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "webservices.dll"
#cfunc global WsPushBytes "WsPushBytes" int, sptr, sptr, int
; res = WsPushBytes(writer, callback, callbackState, error)
; writer : WS_XML_WRITER* -> "int"
; callback : WS_PUSH_BYTES_CALLBACK -> "sptr"
; callbackState : void* optional -> "sptr"
; error : WS_ERROR* optional -> "int"
; HRESULT WsPushBytes(WS_XML_WRITER* writer, WS_PUSH_BYTES_CALLBACK callback, void* callbackState, WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsPushBytes "WsPushBytes" int, intptr, intptr, int
; res = WsPushBytes(writer, callback, callbackState, error)
; writer : WS_XML_WRITER* -> "int"
; callback : WS_PUSH_BYTES_CALLBACK -> "intptr"
; callbackState : void* optional -> "intptr"
; error : WS_ERROR* optional -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsPushBytes = webservices.NewProc("WsPushBytes")
)

// writer (WS_XML_WRITER*), callback (WS_PUSH_BYTES_CALLBACK), callbackState (void* optional), error (WS_ERROR* optional)
r1, _, err := procWsPushBytes.Call(
	uintptr(writer),
	uintptr(callback),
	uintptr(callbackState),
	uintptr(error),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WsPushBytes(
  writer: Pointer;   // WS_XML_WRITER*
  callback: Pointer;   // WS_PUSH_BYTES_CALLBACK
  callbackState: Pointer;   // void* optional
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsPushBytes';
result := DllCall("webservices\WsPushBytes"
    , "Ptr", writer   ; WS_XML_WRITER*
    , "Ptr", callback   ; WS_PUSH_BYTES_CALLBACK
    , "Ptr", callbackState   ; void* optional
    , "Ptr", error   ; WS_ERROR* optional
    , "Int")   ; return: HRESULT
●WsPushBytes(writer, callback, callbackState, error) = DLL("webservices.dll", "int WsPushBytes(void*, void*, void*, void*)")
# 呼び出し: WsPushBytes(writer, callback, callbackState, error)
# writer : WS_XML_WRITER* -> "void*"
# callback : WS_PUSH_BYTES_CALLBACK -> "void*"
# callbackState : void* optional -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。