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

WsResetError

関数
エラーオブジェクトを再利用可能にリセットする。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WsResetError(
    WS_ERROR* error
);

パラメーター

名前方向説明
errorWS_ERROR*in蓄積した情報を消去して初期状態に戻す対象のWS_ERRORオブジェクト。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsResetError(
    WS_ERROR* error
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsResetError(
    ref IntPtr error   // WS_ERROR*
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsResetError(
    ByRef [error] As IntPtr   ' WS_ERROR*
) As Integer
End Function
' error : WS_ERROR*
Declare PtrSafe Function WsResetError Lib "webservices" ( _
    ByRef error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WsResetError = ctypes.windll.webservices.WsResetError
WsResetError.restype = ctypes.c_int
WsResetError.argtypes = [
    ctypes.c_void_p,  # error : WS_ERROR*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webservices.dll')
WsResetError = Fiddle::Function.new(
  lib['WsResetError'],
  [
    Fiddle::TYPE_VOIDP,  # error : WS_ERROR*
  ],
  Fiddle::TYPE_INT)
#[link(name = "webservices")]
extern "system" {
    fn WsResetError(
        error: *mut isize  // WS_ERROR*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("webservices.dll")]
public static extern int WsResetError(ref IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsResetError' -Namespace Win32 -PassThru
# $api::WsResetError(error)
#uselib "webservices.dll"
#func global WsResetError "WsResetError" sptr
; WsResetError varptr(error)   ; 戻り値は stat
; error : WS_ERROR* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "webservices.dll"
#cfunc global WsResetError "WsResetError" var
; res = WsResetError(error)
; error : WS_ERROR* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WsResetError(WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsResetError "WsResetError" var
; res = WsResetError(error)
; error : WS_ERROR* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsResetError = webservices.NewProc("WsResetError")
)

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

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

foreign import stdcall safe "WsResetError"
  c_WsResetError :: Ptr CIntPtr -> IO Int32
-- error : WS_ERROR* -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wsreseterror =
  foreign "WsResetError"
    ((ptr intptr_t) @-> returning int32_t)
(* error : 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 ("WsResetError" ws-reset-error :convention :stdcall) :int32
  (error :pointer))   ; WS_ERROR*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WsResetError = Win32::API::More->new('webservices',
    'int WsResetError(LPVOID error)');
# my $ret = $WsResetError->Call($error);
# error : WS_ERROR* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。