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