ホーム › Networking.WindowsWebServices › WsGetErrorString
WsGetErrorString
関数エラーオブジェクトから文字列を取得する。
シグネチャ
// webservices.dll
#include <windows.h>
HRESULT WsGetErrorString(
WS_ERROR* error,
DWORD index,
WS_STRING* string
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| error | WS_ERROR* | in |
| index | DWORD | in |
| string | WS_STRING* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// webservices.dll
#include <windows.h>
HRESULT WsGetErrorString(
WS_ERROR* error,
DWORD index,
WS_STRING* string
);[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsGetErrorString(
ref IntPtr error, // WS_ERROR*
uint index, // DWORD
IntPtr string // WS_STRING* out
);<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsGetErrorString(
ByRef [error] As IntPtr, ' WS_ERROR*
index As UInteger, ' DWORD
[string] As IntPtr ' WS_STRING* out
) As Integer
End Function' error : WS_ERROR*
' index : DWORD
' string : WS_STRING* out
Declare PtrSafe Function WsGetErrorString Lib "webservices" ( _
ByRef error As LongPtr, _
ByVal index As Long, _
ByVal string As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WsGetErrorString = ctypes.windll.webservices.WsGetErrorString
WsGetErrorString.restype = ctypes.c_int
WsGetErrorString.argtypes = [
ctypes.c_void_p, # error : WS_ERROR*
wintypes.DWORD, # index : DWORD
ctypes.c_void_p, # string : WS_STRING* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('webservices.dll')
WsGetErrorString = Fiddle::Function.new(
lib['WsGetErrorString'],
[
Fiddle::TYPE_VOIDP, # error : WS_ERROR*
-Fiddle::TYPE_INT, # index : DWORD
Fiddle::TYPE_VOIDP, # string : WS_STRING* out
],
Fiddle::TYPE_INT)#[link(name = "webservices")]
extern "system" {
fn WsGetErrorString(
error: *mut isize, // WS_ERROR*
index: u32, // DWORD
string: *mut WS_STRING // WS_STRING* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("webservices.dll")]
public static extern int WsGetErrorString(ref IntPtr error, uint index, IntPtr string);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsGetErrorString' -Namespace Win32 -PassThru
# $api::WsGetErrorString(error, index, string)#uselib "webservices.dll"
#func global WsGetErrorString "WsGetErrorString" sptr, sptr, sptr
; WsGetErrorString error, index, varptr(string) ; 戻り値は stat
; error : WS_ERROR* -> "sptr"
; index : DWORD -> "sptr"
; string : WS_STRING* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "webservices.dll" #cfunc global WsGetErrorString "WsGetErrorString" int, int, var ; res = WsGetErrorString(error, index, string) ; error : WS_ERROR* -> "int" ; index : DWORD -> "int" ; string : WS_STRING* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "webservices.dll" #cfunc global WsGetErrorString "WsGetErrorString" int, int, sptr ; res = WsGetErrorString(error, index, varptr(string)) ; error : WS_ERROR* -> "int" ; index : DWORD -> "int" ; string : WS_STRING* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WsGetErrorString(WS_ERROR* error, DWORD index, WS_STRING* string) #uselib "webservices.dll" #cfunc global WsGetErrorString "WsGetErrorString" int, int, var ; res = WsGetErrorString(error, index, string) ; error : WS_ERROR* -> "int" ; index : DWORD -> "int" ; string : WS_STRING* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WsGetErrorString(WS_ERROR* error, DWORD index, WS_STRING* string) #uselib "webservices.dll" #cfunc global WsGetErrorString "WsGetErrorString" int, int, intptr ; res = WsGetErrorString(error, index, varptr(string)) ; error : WS_ERROR* -> "int" ; index : DWORD -> "int" ; string : WS_STRING* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
webservices = windows.NewLazySystemDLL("webservices.dll")
procWsGetErrorString = webservices.NewProc("WsGetErrorString")
)
// error (WS_ERROR*), index (DWORD), string (WS_STRING* out)
r1, _, err := procWsGetErrorString.Call(
uintptr(error),
uintptr(index),
uintptr(string),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WsGetErrorString(
error: Pointer; // WS_ERROR*
index: DWORD; // DWORD
string: Pointer // WS_STRING* out
): Integer; stdcall;
external 'webservices.dll' name 'WsGetErrorString';result := DllCall("webservices\WsGetErrorString"
, "Ptr", error ; WS_ERROR*
, "UInt", index ; DWORD
, "Ptr", string ; WS_STRING* out
, "Int") ; return: HRESULT●WsGetErrorString(error, index, string) = DLL("webservices.dll", "int WsGetErrorString(void*, dword, void*)")
# 呼び出し: WsGetErrorString(error, index, string)
# error : WS_ERROR* -> "void*"
# index : DWORD -> "dword"
# string : WS_STRING* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。