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