ホーム › Networking.WindowsWebServices › WsCreateError
WsCreateError
関数エラーオブジェクトを作成する。
シグネチャ
// webservices.dll
#include <windows.h>
HRESULT WsCreateError(
const WS_ERROR_PROPERTY* properties, // optional
DWORD propertyCount,
WS_ERROR** error
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| properties | WS_ERROR_PROPERTY* | inoptional | エラーオブジェクトの構成プロパティ配列(言語等)。NULL可。 |
| propertyCount | DWORD | in | properties配列の要素数。 |
| error | WS_ERROR** | out | 生成されたWS_ERRORオブジェクトを受け取る出力ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// webservices.dll
#include <windows.h>
HRESULT WsCreateError(
const WS_ERROR_PROPERTY* properties, // optional
DWORD propertyCount,
WS_ERROR** error
);[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsCreateError(
IntPtr properties, // WS_ERROR_PROPERTY* optional
uint propertyCount, // DWORD
IntPtr error // WS_ERROR** out
);<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsCreateError(
properties As IntPtr, ' WS_ERROR_PROPERTY* optional
propertyCount As UInteger, ' DWORD
[error] As IntPtr ' WS_ERROR** out
) As Integer
End Function' properties : WS_ERROR_PROPERTY* optional
' propertyCount : DWORD
' error : WS_ERROR** out
Declare PtrSafe Function WsCreateError Lib "webservices" ( _
ByVal properties As LongPtr, _
ByVal propertyCount 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
WsCreateError = ctypes.windll.webservices.WsCreateError
WsCreateError.restype = ctypes.c_int
WsCreateError.argtypes = [
ctypes.c_void_p, # properties : WS_ERROR_PROPERTY* optional
wintypes.DWORD, # propertyCount : DWORD
ctypes.c_void_p, # error : WS_ERROR** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('webservices.dll')
WsCreateError = Fiddle::Function.new(
lib['WsCreateError'],
[
Fiddle::TYPE_VOIDP, # properties : WS_ERROR_PROPERTY* optional
-Fiddle::TYPE_INT, # propertyCount : DWORD
Fiddle::TYPE_VOIDP, # error : WS_ERROR** out
],
Fiddle::TYPE_INT)#[link(name = "webservices")]
extern "system" {
fn WsCreateError(
properties: *const WS_ERROR_PROPERTY, // WS_ERROR_PROPERTY* optional
propertyCount: u32, // DWORD
error: *mut *mut isize // WS_ERROR** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("webservices.dll")]
public static extern int WsCreateError(IntPtr properties, uint propertyCount, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsCreateError' -Namespace Win32 -PassThru
# $api::WsCreateError(properties, propertyCount, error)#uselib "webservices.dll"
#func global WsCreateError "WsCreateError" sptr, sptr, sptr
; WsCreateError varptr(properties), propertyCount, varptr(error) ; 戻り値は stat
; properties : WS_ERROR_PROPERTY* optional -> "sptr"
; propertyCount : DWORD -> "sptr"
; error : WS_ERROR** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "webservices.dll" #cfunc global WsCreateError "WsCreateError" var, int, var ; res = WsCreateError(properties, propertyCount, error) ; properties : WS_ERROR_PROPERTY* optional -> "var" ; propertyCount : DWORD -> "int" ; error : WS_ERROR** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "webservices.dll" #cfunc global WsCreateError "WsCreateError" sptr, int, sptr ; res = WsCreateError(varptr(properties), propertyCount, varptr(error)) ; properties : WS_ERROR_PROPERTY* optional -> "sptr" ; propertyCount : DWORD -> "int" ; error : WS_ERROR** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WsCreateError(WS_ERROR_PROPERTY* properties, DWORD propertyCount, WS_ERROR** error) #uselib "webservices.dll" #cfunc global WsCreateError "WsCreateError" var, int, var ; res = WsCreateError(properties, propertyCount, error) ; properties : WS_ERROR_PROPERTY* optional -> "var" ; propertyCount : DWORD -> "int" ; error : WS_ERROR** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WsCreateError(WS_ERROR_PROPERTY* properties, DWORD propertyCount, WS_ERROR** error) #uselib "webservices.dll" #cfunc global WsCreateError "WsCreateError" intptr, int, intptr ; res = WsCreateError(varptr(properties), propertyCount, varptr(error)) ; properties : WS_ERROR_PROPERTY* optional -> "intptr" ; propertyCount : DWORD -> "int" ; error : WS_ERROR** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
webservices = windows.NewLazySystemDLL("webservices.dll")
procWsCreateError = webservices.NewProc("WsCreateError")
)
// properties (WS_ERROR_PROPERTY* optional), propertyCount (DWORD), error (WS_ERROR** out)
r1, _, err := procWsCreateError.Call(
uintptr(properties),
uintptr(propertyCount),
uintptr(error),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WsCreateError(
properties: Pointer; // WS_ERROR_PROPERTY* optional
propertyCount: DWORD; // DWORD
error: Pointer // WS_ERROR** out
): Integer; stdcall;
external 'webservices.dll' name 'WsCreateError';result := DllCall("webservices\WsCreateError"
, "Ptr", properties ; WS_ERROR_PROPERTY* optional
, "UInt", propertyCount ; DWORD
, "Ptr", error ; WS_ERROR** out
, "Int") ; return: HRESULT●WsCreateError(properties, propertyCount, error) = DLL("webservices.dll", "int WsCreateError(void*, dword, void*)")
# 呼び出し: WsCreateError(properties, propertyCount, error)
# properties : WS_ERROR_PROPERTY* optional -> "void*"
# propertyCount : DWORD -> "dword"
# error : WS_ERROR** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "webservices" fn WsCreateError(
properties: [*c]WS_ERROR_PROPERTY, // WS_ERROR_PROPERTY* optional
propertyCount: u32, // DWORD
error: [*c][*c]isize // WS_ERROR** out
) callconv(std.os.windows.WINAPI) i32;proc WsCreateError(
properties: ptr WS_ERROR_PROPERTY, # WS_ERROR_PROPERTY* optional
propertyCount: uint32, # DWORD
error: ptr int # WS_ERROR** out
): int32 {.importc: "WsCreateError", stdcall, dynlib: "webservices.dll".}pragma(lib, "webservices");
extern(Windows)
int WsCreateError(
WS_ERROR_PROPERTY* properties, // WS_ERROR_PROPERTY* optional
uint propertyCount, // DWORD
ptrdiff_t** error // WS_ERROR** out
);ccall((:WsCreateError, "webservices.dll"), stdcall, Int32,
(Ptr{WS_ERROR_PROPERTY}, UInt32, Ptr{Int}),
properties, propertyCount, error)
# properties : WS_ERROR_PROPERTY* optional -> Ptr{WS_ERROR_PROPERTY}
# propertyCount : DWORD -> UInt32
# error : WS_ERROR** out -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WsCreateError(
void* properties,
uint32_t propertyCount,
intptr_t** error);
]]
local webservices = ffi.load("webservices")
-- webservices.WsCreateError(properties, propertyCount, error)
-- properties : WS_ERROR_PROPERTY* optional
-- propertyCount : DWORD
-- error : WS_ERROR** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('webservices.dll');
const WsCreateError = lib.func('__stdcall', 'WsCreateError', 'int32_t', ['void *', 'uint32_t', 'intptr_t *']);
// WsCreateError(properties, propertyCount, error)
// properties : WS_ERROR_PROPERTY* optional -> 'void *'
// propertyCount : DWORD -> 'uint32_t'
// error : WS_ERROR** out -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("webservices.dll", {
WsCreateError: { parameters: ["pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.WsCreateError(properties, propertyCount, error)
// properties : WS_ERROR_PROPERTY* optional -> "pointer"
// propertyCount : DWORD -> "u32"
// error : WS_ERROR** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WsCreateError(
void* properties,
uint32_t propertyCount,
intptr_t** error);
C, "webservices.dll");
// $ffi->WsCreateError(properties, propertyCount, error);
// properties : WS_ERROR_PROPERTY* optional
// propertyCount : DWORD
// error : WS_ERROR** out
// 構造体/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 WsCreateError(
Pointer properties, // WS_ERROR_PROPERTY* optional
int propertyCount, // DWORD
Pointer error // WS_ERROR** out
);
}@[Link("webservices")]
lib Libwebservices
fun WsCreateError = WsCreateError(
properties : WS_ERROR_PROPERTY*, # WS_ERROR_PROPERTY* optional
propertyCount : UInt32, # DWORD
error : LibC::SSizeT** # WS_ERROR** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WsCreateErrorNative = Int32 Function(Pointer<Void>, Uint32, Pointer<IntPtr>);
typedef WsCreateErrorDart = int Function(Pointer<Void>, int, Pointer<IntPtr>);
final WsCreateError = DynamicLibrary.open('webservices.dll')
.lookupFunction<WsCreateErrorNative, WsCreateErrorDart>('WsCreateError');
// properties : WS_ERROR_PROPERTY* optional -> Pointer<Void>
// propertyCount : DWORD -> Uint32
// error : WS_ERROR** out -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WsCreateError(
properties: Pointer; // WS_ERROR_PROPERTY* optional
propertyCount: DWORD; // DWORD
error: Pointer // WS_ERROR** out
): Integer; stdcall;
external 'webservices.dll' name 'WsCreateError';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WsCreateError"
c_WsCreateError :: Ptr () -> Word32 -> Ptr CIntPtr -> IO Int32
-- properties : WS_ERROR_PROPERTY* optional -> Ptr ()
-- propertyCount : DWORD -> Word32
-- error : WS_ERROR** out -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wscreateerror =
foreign "WsCreateError"
((ptr void) @-> uint32_t @-> (ptr intptr_t) @-> returning int32_t)
(* properties : WS_ERROR_PROPERTY* optional -> (ptr void) *)
(* propertyCount : DWORD -> uint32_t *)
(* error : WS_ERROR** out -> (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 ("WsCreateError" ws-create-error :convention :stdcall) :int32
(properties :pointer) ; WS_ERROR_PROPERTY* optional
(property-count :uint32) ; DWORD
(error :pointer)) ; WS_ERROR** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WsCreateError = Win32::API::More->new('webservices',
'int WsCreateError(LPVOID properties, DWORD propertyCount, LPVOID error)');
# my $ret = $WsCreateError->Call($properties, $propertyCount, $error);
# properties : WS_ERROR_PROPERTY* optional -> LPVOID
# propertyCount : DWORD -> DWORD
# error : WS_ERROR** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型