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

WsWriteType

関数
指定型の値をシリアライズしXMLライターに書き込む。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WsWriteType(
    WS_XML_WRITER* writer,
    WS_TYPE_MAPPING typeMapping,
    WS_TYPE type,
    const void* typeDescription,   // optional
    WS_WRITE_OPTION writeOption,
    const void* value,   // optional
    DWORD valueSize,
    WS_ERROR* error   // optional
);

パラメーター

名前方向説明
writerWS_XML_WRITER*in出力先のWS_XML_WRITER。
typeMappingWS_TYPE_MAPPINGin値とXMLの対応付け方法を示すWS_TYPE_MAPPING列挙値。
typeWS_TYPEinシリアライズする値の型を示すWS_TYPE列挙値。
typeDescriptionvoid*inoptional型に対応する詳細記述構造体へのポインタ。型によりNULL可。
writeOptionWS_WRITE_OPTIONin値の必須有無やNULL扱いを示すWS_WRITE_OPTION。
valuevoid*inoptional書き込む値を格納したバッファへのポインタ。
valueSizeDWORDinvalueバッファのバイトサイズを指定する。
errorWS_ERROR*inoptional詳細なエラー情報を格納するWS_ERRORオブジェクト。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsWriteType(
    WS_XML_WRITER* writer,
    WS_TYPE_MAPPING typeMapping,
    WS_TYPE type,
    const void* typeDescription,   // optional
    WS_WRITE_OPTION writeOption,
    const void* value,   // optional
    DWORD valueSize,
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsWriteType(
    ref IntPtr writer,   // WS_XML_WRITER*
    int typeMapping,   // WS_TYPE_MAPPING
    int type,   // WS_TYPE
    IntPtr typeDescription,   // void* optional
    int writeOption,   // WS_WRITE_OPTION
    IntPtr value,   // void* optional
    uint valueSize,   // DWORD
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsWriteType(
    ByRef writer As IntPtr,   ' WS_XML_WRITER*
    typeMapping As Integer,   ' WS_TYPE_MAPPING
    type As Integer,   ' WS_TYPE
    typeDescription As IntPtr,   ' void* optional
    writeOption As Integer,   ' WS_WRITE_OPTION
    value As IntPtr,   ' void* optional
    valueSize As UInteger,   ' DWORD
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' writer : WS_XML_WRITER*
' typeMapping : WS_TYPE_MAPPING
' type : WS_TYPE
' typeDescription : void* optional
' writeOption : WS_WRITE_OPTION
' value : void* optional
' valueSize : DWORD
' error : WS_ERROR* optional
Declare PtrSafe Function WsWriteType Lib "webservices" ( _
    ByRef writer As LongPtr, _
    ByVal typeMapping As Long, _
    ByVal type As Long, _
    ByVal typeDescription As LongPtr, _
    ByVal writeOption As Long, _
    ByVal value As LongPtr, _
    ByVal valueSize As Long, _
    ByVal error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WsWriteType = ctypes.windll.webservices.WsWriteType
WsWriteType.restype = ctypes.c_int
WsWriteType.argtypes = [
    ctypes.c_void_p,  # writer : WS_XML_WRITER*
    ctypes.c_int,  # typeMapping : WS_TYPE_MAPPING
    ctypes.c_int,  # type : WS_TYPE
    ctypes.POINTER(None),  # typeDescription : void* optional
    ctypes.c_int,  # writeOption : WS_WRITE_OPTION
    ctypes.POINTER(None),  # value : void* optional
    wintypes.DWORD,  # valueSize : DWORD
    ctypes.c_void_p,  # error : WS_ERROR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webservices.dll')
WsWriteType = Fiddle::Function.new(
  lib['WsWriteType'],
  [
    Fiddle::TYPE_VOIDP,  # writer : WS_XML_WRITER*
    Fiddle::TYPE_INT,  # typeMapping : WS_TYPE_MAPPING
    Fiddle::TYPE_INT,  # type : WS_TYPE
    Fiddle::TYPE_VOIDP,  # typeDescription : void* optional
    Fiddle::TYPE_INT,  # writeOption : WS_WRITE_OPTION
    Fiddle::TYPE_VOIDP,  # value : void* optional
    -Fiddle::TYPE_INT,  # valueSize : DWORD
    Fiddle::TYPE_VOIDP,  # error : WS_ERROR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "webservices")]
extern "system" {
    fn WsWriteType(
        writer: *mut isize,  // WS_XML_WRITER*
        typeMapping: i32,  // WS_TYPE_MAPPING
        type: i32,  // WS_TYPE
        typeDescription: *const (),  // void* optional
        writeOption: i32,  // WS_WRITE_OPTION
        value: *const (),  // void* optional
        valueSize: u32,  // DWORD
        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 WsWriteType(ref IntPtr writer, int typeMapping, int type, IntPtr typeDescription, int writeOption, IntPtr value, uint valueSize, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsWriteType' -Namespace Win32 -PassThru
# $api::WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error)
#uselib "webservices.dll"
#func global WsWriteType "WsWriteType" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WsWriteType varptr(writer), typeMapping, type, typeDescription, writeOption, value, valueSize, varptr(error)   ; 戻り値は stat
; writer : WS_XML_WRITER* -> "sptr"
; typeMapping : WS_TYPE_MAPPING -> "sptr"
; type : WS_TYPE -> "sptr"
; typeDescription : void* optional -> "sptr"
; writeOption : WS_WRITE_OPTION -> "sptr"
; value : void* optional -> "sptr"
; valueSize : DWORD -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "webservices.dll"
#cfunc global WsWriteType "WsWriteType" var, int, int, sptr, int, sptr, int, var
; res = WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error)
; writer : WS_XML_WRITER* -> "var"
; typeMapping : WS_TYPE_MAPPING -> "int"
; type : WS_TYPE -> "int"
; typeDescription : void* optional -> "sptr"
; writeOption : WS_WRITE_OPTION -> "int"
; value : void* optional -> "sptr"
; valueSize : DWORD -> "int"
; error : WS_ERROR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WsWriteType(WS_XML_WRITER* writer, WS_TYPE_MAPPING typeMapping, WS_TYPE type, void* typeDescription, WS_WRITE_OPTION writeOption, void* value, DWORD valueSize, WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsWriteType "WsWriteType" var, int, int, intptr, int, intptr, int, var
; res = WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error)
; writer : WS_XML_WRITER* -> "var"
; typeMapping : WS_TYPE_MAPPING -> "int"
; type : WS_TYPE -> "int"
; typeDescription : void* optional -> "intptr"
; writeOption : WS_WRITE_OPTION -> "int"
; value : void* optional -> "intptr"
; valueSize : DWORD -> "int"
; error : WS_ERROR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsWriteType = webservices.NewProc("WsWriteType")
)

// writer (WS_XML_WRITER*), typeMapping (WS_TYPE_MAPPING), type (WS_TYPE), typeDescription (void* optional), writeOption (WS_WRITE_OPTION), value (void* optional), valueSize (DWORD), error (WS_ERROR* optional)
r1, _, err := procWsWriteType.Call(
	uintptr(writer),
	uintptr(typeMapping),
	uintptr(type),
	uintptr(typeDescription),
	uintptr(writeOption),
	uintptr(value),
	uintptr(valueSize),
	uintptr(error),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WsWriteType(
  writer: Pointer;   // WS_XML_WRITER*
  typeMapping: Integer;   // WS_TYPE_MAPPING
  type: Integer;   // WS_TYPE
  typeDescription: Pointer;   // void* optional
  writeOption: Integer;   // WS_WRITE_OPTION
  value: Pointer;   // void* optional
  valueSize: DWORD;   // DWORD
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsWriteType';
result := DllCall("webservices\WsWriteType"
    , "Ptr", writer   ; WS_XML_WRITER*
    , "Int", typeMapping   ; WS_TYPE_MAPPING
    , "Int", type   ; WS_TYPE
    , "Ptr", typeDescription   ; void* optional
    , "Int", writeOption   ; WS_WRITE_OPTION
    , "Ptr", value   ; void* optional
    , "UInt", valueSize   ; DWORD
    , "Ptr", error   ; WS_ERROR* optional
    , "Int")   ; return: HRESULT
●WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error) = DLL("webservices.dll", "int WsWriteType(void*, int, int, void*, int, void*, dword, void*)")
# 呼び出し: WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error)
# writer : WS_XML_WRITER* -> "void*"
# typeMapping : WS_TYPE_MAPPING -> "int"
# type : WS_TYPE -> "int"
# typeDescription : void* optional -> "void*"
# writeOption : WS_WRITE_OPTION -> "int"
# value : void* optional -> "void*"
# valueSize : DWORD -> "dword"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "webservices" fn WsWriteType(
    writer: [*c]isize, // WS_XML_WRITER*
    typeMapping: i32, // WS_TYPE_MAPPING
    type: i32, // WS_TYPE
    typeDescription: ?*anyopaque, // void* optional
    writeOption: i32, // WS_WRITE_OPTION
    value: ?*anyopaque, // void* optional
    valueSize: u32, // DWORD
    error: [*c]isize // WS_ERROR* optional
) callconv(std.os.windows.WINAPI) i32;
proc WsWriteType(
    writer: ptr int,  # WS_XML_WRITER*
    typeMapping: int32,  # WS_TYPE_MAPPING
    `type`: int32,  # WS_TYPE
    typeDescription: pointer,  # void* optional
    writeOption: int32,  # WS_WRITE_OPTION
    value: pointer,  # void* optional
    valueSize: uint32,  # DWORD
    error: ptr int  # WS_ERROR* optional
): int32 {.importc: "WsWriteType", stdcall, dynlib: "webservices.dll".}
pragma(lib, "webservices");
extern(Windows)
int WsWriteType(
    ptrdiff_t* writer,   // WS_XML_WRITER*
    int typeMapping,   // WS_TYPE_MAPPING
    int type,   // WS_TYPE
    void* typeDescription,   // void* optional
    int writeOption,   // WS_WRITE_OPTION
    void* value,   // void* optional
    uint valueSize,   // DWORD
    ptrdiff_t* error   // WS_ERROR* optional
);
ccall((:WsWriteType, "webservices.dll"), stdcall, Int32,
      (Ptr{Int}, Int32, Int32, Ptr{Cvoid}, Int32, Ptr{Cvoid}, UInt32, Ptr{Int}),
      writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error)
# writer : WS_XML_WRITER* -> Ptr{Int}
# typeMapping : WS_TYPE_MAPPING -> Int32
# type : WS_TYPE -> Int32
# typeDescription : void* optional -> Ptr{Cvoid}
# writeOption : WS_WRITE_OPTION -> Int32
# value : void* optional -> Ptr{Cvoid}
# valueSize : DWORD -> UInt32
# error : WS_ERROR* optional -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WsWriteType(
    intptr_t* writer,
    int32_t typeMapping,
    int32_t type,
    void* typeDescription,
    int32_t writeOption,
    void* value,
    uint32_t valueSize,
    intptr_t* error);
]]
local webservices = ffi.load("webservices")
-- webservices.WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error)
-- writer : WS_XML_WRITER*
-- typeMapping : WS_TYPE_MAPPING
-- type : WS_TYPE
-- typeDescription : void* optional
-- writeOption : WS_WRITE_OPTION
-- value : void* optional
-- valueSize : DWORD
-- error : WS_ERROR* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('webservices.dll');
const WsWriteType = lib.func('__stdcall', 'WsWriteType', 'int32_t', ['intptr_t *', 'int32_t', 'int32_t', 'void *', 'int32_t', 'void *', 'uint32_t', 'intptr_t *']);
// WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error)
// writer : WS_XML_WRITER* -> 'intptr_t *'
// typeMapping : WS_TYPE_MAPPING -> 'int32_t'
// type : WS_TYPE -> 'int32_t'
// typeDescription : void* optional -> 'void *'
// writeOption : WS_WRITE_OPTION -> 'int32_t'
// value : void* optional -> 'void *'
// valueSize : DWORD -> 'uint32_t'
// error : WS_ERROR* optional -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("webservices.dll", {
  WsWriteType: { parameters: ["pointer", "i32", "i32", "pointer", "i32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error)
// writer : WS_XML_WRITER* -> "pointer"
// typeMapping : WS_TYPE_MAPPING -> "i32"
// type : WS_TYPE -> "i32"
// typeDescription : void* optional -> "pointer"
// writeOption : WS_WRITE_OPTION -> "i32"
// value : void* optional -> "pointer"
// valueSize : DWORD -> "u32"
// error : WS_ERROR* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WsWriteType(
    intptr_t* writer,
    int32_t typeMapping,
    int32_t type,
    void* typeDescription,
    int32_t writeOption,
    void* value,
    uint32_t valueSize,
    intptr_t* error);
C, "webservices.dll");
// $ffi->WsWriteType(writer, typeMapping, type, typeDescription, writeOption, value, valueSize, error);
// writer : WS_XML_WRITER*
// typeMapping : WS_TYPE_MAPPING
// type : WS_TYPE
// typeDescription : void* optional
// writeOption : WS_WRITE_OPTION
// value : void* optional
// valueSize : DWORD
// 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 WsWriteType(
        LongByReference writer,   // WS_XML_WRITER*
        int typeMapping,   // WS_TYPE_MAPPING
        int type,   // WS_TYPE
        Pointer typeDescription,   // void* optional
        int writeOption,   // WS_WRITE_OPTION
        Pointer value,   // void* optional
        int valueSize,   // DWORD
        LongByReference error   // WS_ERROR* optional
    );
}
@[Link("webservices")]
lib Libwebservices
  fun WsWriteType = WsWriteType(
    writer : LibC::SSizeT*,   # WS_XML_WRITER*
    typeMapping : Int32,   # WS_TYPE_MAPPING
    type_ : Int32,   # WS_TYPE
    typeDescription : Void*,   # void* optional
    writeOption : Int32,   # WS_WRITE_OPTION
    value : Void*,   # void* optional
    valueSize : UInt32,   # DWORD
    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 WsWriteTypeNative = Int32 Function(Pointer<IntPtr>, Int32, Int32, Pointer<Void>, Int32, Pointer<Void>, Uint32, Pointer<IntPtr>);
typedef WsWriteTypeDart = int Function(Pointer<IntPtr>, int, int, Pointer<Void>, int, Pointer<Void>, int, Pointer<IntPtr>);
final WsWriteType = DynamicLibrary.open('webservices.dll')
    .lookupFunction<WsWriteTypeNative, WsWriteTypeDart>('WsWriteType');
// writer : WS_XML_WRITER* -> Pointer<IntPtr>
// typeMapping : WS_TYPE_MAPPING -> Int32
// type : WS_TYPE -> Int32
// typeDescription : void* optional -> Pointer<Void>
// writeOption : WS_WRITE_OPTION -> Int32
// value : void* optional -> Pointer<Void>
// valueSize : DWORD -> Uint32
// error : WS_ERROR* optional -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WsWriteType(
  writer: Pointer;   // WS_XML_WRITER*
  typeMapping: Integer;   // WS_TYPE_MAPPING
  type: Integer;   // WS_TYPE
  typeDescription: Pointer;   // void* optional
  writeOption: Integer;   // WS_WRITE_OPTION
  value: Pointer;   // void* optional
  valueSize: DWORD;   // DWORD
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsWriteType';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WsWriteType"
  c_WsWriteType :: Ptr CIntPtr -> Int32 -> Int32 -> Ptr () -> Int32 -> Ptr () -> Word32 -> Ptr CIntPtr -> IO Int32
-- writer : WS_XML_WRITER* -> Ptr CIntPtr
-- typeMapping : WS_TYPE_MAPPING -> Int32
-- type : WS_TYPE -> Int32
-- typeDescription : void* optional -> Ptr ()
-- writeOption : WS_WRITE_OPTION -> Int32
-- value : void* optional -> Ptr ()
-- valueSize : DWORD -> Word32
-- error : WS_ERROR* optional -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wswritetype =
  foreign "WsWriteType"
    ((ptr intptr_t) @-> int32_t @-> int32_t @-> (ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> (ptr intptr_t) @-> returning int32_t)
(* writer : WS_XML_WRITER* -> (ptr intptr_t) *)
(* typeMapping : WS_TYPE_MAPPING -> int32_t *)
(* type : WS_TYPE -> int32_t *)
(* typeDescription : void* optional -> (ptr void) *)
(* writeOption : WS_WRITE_OPTION -> int32_t *)
(* value : void* optional -> (ptr void) *)
(* valueSize : DWORD -> uint32_t *)
(* 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 ("WsWriteType" ws-write-type :convention :stdcall) :int32
  (writer :pointer)   ; WS_XML_WRITER*
  (type-mapping :int32)   ; WS_TYPE_MAPPING
  (type :int32)   ; WS_TYPE
  (type-description :pointer)   ; void* optional
  (write-option :int32)   ; WS_WRITE_OPTION
  (value :pointer)   ; void* optional
  (value-size :uint32)   ; DWORD
  (error :pointer))   ; WS_ERROR* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WsWriteType = Win32::API::More->new('webservices',
    'int WsWriteType(LPVOID writer, int typeMapping, int type, LPVOID typeDescription, int writeOption, LPVOID value, DWORD valueSize, LPVOID error)');
# my $ret = $WsWriteType->Call($writer, $typeMapping, $type, $typeDescription, $writeOption, $value, $valueSize, $error);
# writer : WS_XML_WRITER* -> LPVOID
# typeMapping : WS_TYPE_MAPPING -> int
# type : WS_TYPE -> int
# typeDescription : void* optional -> LPVOID
# writeOption : WS_WRITE_OPTION -> int
# value : void* optional -> LPVOID
# valueSize : DWORD -> DWORD
# error : WS_ERROR* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型