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

ResUtilRemoveResourceServiceEnvironment

関数
リソースサービスの環境変数設定を削除する。
DLLRESUTILS.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD ResUtilRemoveResourceServiceEnvironment(
    LPCWSTR pszServiceName,
    PLOG_EVENT_ROUTINE pfnLogEvent,
    INT_PTR hResourceHandle
);

パラメーター

名前方向説明
pszServiceNameLPCWSTRinクラスター環境設定を解除する対象サービスの名前。
pfnLogEventPLOG_EVENT_ROUTINEinエラーや情報を記録するためのログイベントコールバック関数。NULL可。
hResourceHandleINT_PTRinログコールバックに渡されるリソースハンドル(コンテキスト用)。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ResUtilRemoveResourceServiceEnvironment(
    LPCWSTR pszServiceName,
    PLOG_EVENT_ROUTINE pfnLogEvent,
    INT_PTR hResourceHandle
);
[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilRemoveResourceServiceEnvironment(
    [MarshalAs(UnmanagedType.LPWStr)] string pszServiceName,   // LPCWSTR
    IntPtr pfnLogEvent,   // PLOG_EVENT_ROUTINE
    IntPtr hResourceHandle   // INT_PTR
);
<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilRemoveResourceServiceEnvironment(
    <MarshalAs(UnmanagedType.LPWStr)> pszServiceName As String,   ' LPCWSTR
    pfnLogEvent As IntPtr,   ' PLOG_EVENT_ROUTINE
    hResourceHandle As IntPtr   ' INT_PTR
) As UInteger
End Function
' pszServiceName : LPCWSTR
' pfnLogEvent : PLOG_EVENT_ROUTINE
' hResourceHandle : INT_PTR
Declare PtrSafe Function ResUtilRemoveResourceServiceEnvironment Lib "resutils" ( _
    ByVal pszServiceName As LongPtr, _
    ByVal pfnLogEvent As LongPtr, _
    ByVal hResourceHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResUtilRemoveResourceServiceEnvironment = ctypes.windll.resutils.ResUtilRemoveResourceServiceEnvironment
ResUtilRemoveResourceServiceEnvironment.restype = wintypes.DWORD
ResUtilRemoveResourceServiceEnvironment.argtypes = [
    wintypes.LPCWSTR,  # pszServiceName : LPCWSTR
    ctypes.c_void_p,  # pfnLogEvent : PLOG_EVENT_ROUTINE
    ctypes.c_ssize_t,  # hResourceHandle : INT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilRemoveResourceServiceEnvironment = Fiddle::Function.new(
  lib['ResUtilRemoveResourceServiceEnvironment'],
  [
    Fiddle::TYPE_VOIDP,  # pszServiceName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pfnLogEvent : PLOG_EVENT_ROUTINE
    Fiddle::TYPE_INTPTR_T,  # hResourceHandle : INT_PTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "resutils")]
extern "system" {
    fn ResUtilRemoveResourceServiceEnvironment(
        pszServiceName: *const u16,  // LPCWSTR
        pfnLogEvent: *const core::ffi::c_void,  // PLOG_EVENT_ROUTINE
        hResourceHandle: isize  // INT_PTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilRemoveResourceServiceEnvironment([MarshalAs(UnmanagedType.LPWStr)] string pszServiceName, IntPtr pfnLogEvent, IntPtr hResourceHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilRemoveResourceServiceEnvironment' -Namespace Win32 -PassThru
# $api::ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle)
#uselib "RESUTILS.dll"
#func global ResUtilRemoveResourceServiceEnvironment "ResUtilRemoveResourceServiceEnvironment" sptr, sptr, sptr
; ResUtilRemoveResourceServiceEnvironment pszServiceName, pfnLogEvent, hResourceHandle   ; 戻り値は stat
; pszServiceName : LPCWSTR -> "sptr"
; pfnLogEvent : PLOG_EVENT_ROUTINE -> "sptr"
; hResourceHandle : INT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "RESUTILS.dll"
#cfunc global ResUtilRemoveResourceServiceEnvironment "ResUtilRemoveResourceServiceEnvironment" wstr, sptr, sptr
; res = ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle)
; pszServiceName : LPCWSTR -> "wstr"
; pfnLogEvent : PLOG_EVENT_ROUTINE -> "sptr"
; hResourceHandle : INT_PTR -> "sptr"
; DWORD ResUtilRemoveResourceServiceEnvironment(LPCWSTR pszServiceName, PLOG_EVENT_ROUTINE pfnLogEvent, INT_PTR hResourceHandle)
#uselib "RESUTILS.dll"
#cfunc global ResUtilRemoveResourceServiceEnvironment "ResUtilRemoveResourceServiceEnvironment" wstr, intptr, intptr
; res = ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle)
; pszServiceName : LPCWSTR -> "wstr"
; pfnLogEvent : PLOG_EVENT_ROUTINE -> "intptr"
; hResourceHandle : INT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilRemoveResourceServiceEnvironment = resutils.NewProc("ResUtilRemoveResourceServiceEnvironment")
)

// pszServiceName (LPCWSTR), pfnLogEvent (PLOG_EVENT_ROUTINE), hResourceHandle (INT_PTR)
r1, _, err := procResUtilRemoveResourceServiceEnvironment.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszServiceName))),
	uintptr(pfnLogEvent),
	uintptr(hResourceHandle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ResUtilRemoveResourceServiceEnvironment(
  pszServiceName: PWideChar;   // LPCWSTR
  pfnLogEvent: Pointer;   // PLOG_EVENT_ROUTINE
  hResourceHandle: NativeInt   // INT_PTR
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilRemoveResourceServiceEnvironment';
result := DllCall("RESUTILS\ResUtilRemoveResourceServiceEnvironment"
    , "WStr", pszServiceName   ; LPCWSTR
    , "Ptr", pfnLogEvent   ; PLOG_EVENT_ROUTINE
    , "Ptr", hResourceHandle   ; INT_PTR
    , "UInt")   ; return: DWORD
●ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle) = DLL("RESUTILS.dll", "dword ResUtilRemoveResourceServiceEnvironment(char*, void*, int)")
# 呼び出し: ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle)
# pszServiceName : LPCWSTR -> "char*"
# pfnLogEvent : PLOG_EVENT_ROUTINE -> "void*"
# hResourceHandle : INT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "resutils" fn ResUtilRemoveResourceServiceEnvironment(
    pszServiceName: [*c]const u16, // LPCWSTR
    pfnLogEvent: ?*anyopaque, // PLOG_EVENT_ROUTINE
    hResourceHandle: isize // INT_PTR
) callconv(std.os.windows.WINAPI) u32;
proc ResUtilRemoveResourceServiceEnvironment(
    pszServiceName: WideCString,  # LPCWSTR
    pfnLogEvent: pointer,  # PLOG_EVENT_ROUTINE
    hResourceHandle: int  # INT_PTR
): uint32 {.importc: "ResUtilRemoveResourceServiceEnvironment", stdcall, dynlib: "RESUTILS.dll".}
pragma(lib, "resutils");
extern(Windows)
uint ResUtilRemoveResourceServiceEnvironment(
    const(wchar)* pszServiceName,   // LPCWSTR
    void* pfnLogEvent,   // PLOG_EVENT_ROUTINE
    ptrdiff_t hResourceHandle   // INT_PTR
);
ccall((:ResUtilRemoveResourceServiceEnvironment, "RESUTILS.dll"), stdcall, UInt32,
      (Cwstring, Ptr{Cvoid}, Int),
      pszServiceName, pfnLogEvent, hResourceHandle)
# pszServiceName : LPCWSTR -> Cwstring
# pfnLogEvent : PLOG_EVENT_ROUTINE -> Ptr{Cvoid}
# hResourceHandle : INT_PTR -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilRemoveResourceServiceEnvironment(
    const uint16_t* pszServiceName,
    void* pfnLogEvent,
    intptr_t hResourceHandle);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle)
-- pszServiceName : LPCWSTR
-- pfnLogEvent : PLOG_EVENT_ROUTINE
-- hResourceHandle : INT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilRemoveResourceServiceEnvironment = lib.func('__stdcall', 'ResUtilRemoveResourceServiceEnvironment', 'uint32_t', ['str16', 'void *', 'intptr_t']);
// ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle)
// pszServiceName : LPCWSTR -> 'str16'
// pfnLogEvent : PLOG_EVENT_ROUTINE -> 'void *'
// hResourceHandle : INT_PTR -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("RESUTILS.dll", {
  ResUtilRemoveResourceServiceEnvironment: { parameters: ["buffer", "pointer", "isize"], result: "u32" },
});
// lib.symbols.ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle)
// pszServiceName : LPCWSTR -> "buffer"
// pfnLogEvent : PLOG_EVENT_ROUTINE -> "pointer"
// hResourceHandle : INT_PTR -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilRemoveResourceServiceEnvironment(
    const uint16_t* pszServiceName,
    void* pfnLogEvent,
    intptr_t hResourceHandle);
C, "RESUTILS.dll");
// $ffi->ResUtilRemoveResourceServiceEnvironment(pszServiceName, pfnLogEvent, hResourceHandle);
// pszServiceName : LPCWSTR
// pfnLogEvent : PLOG_EVENT_ROUTINE
// hResourceHandle : INT_PTR
// 構造体/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 Resutils extends StdCallLibrary {
    Resutils INSTANCE = Native.load("resutils", Resutils.class);
    int ResUtilRemoveResourceServiceEnvironment(
        WString pszServiceName,   // LPCWSTR
        Callback pfnLogEvent,   // PLOG_EVENT_ROUTINE
        long hResourceHandle   // INT_PTR
    );
}
@[Link("resutils")]
lib LibRESUTILS
  fun ResUtilRemoveResourceServiceEnvironment = ResUtilRemoveResourceServiceEnvironment(
    pszServiceName : UInt16*,   # LPCWSTR
    pfnLogEvent : Void*,   # PLOG_EVENT_ROUTINE
    hResourceHandle : LibC::SSizeT   # INT_PTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ResUtilRemoveResourceServiceEnvironmentNative = Uint32 Function(Pointer<Utf16>, Pointer<Void>, IntPtr);
typedef ResUtilRemoveResourceServiceEnvironmentDart = int Function(Pointer<Utf16>, Pointer<Void>, int);
final ResUtilRemoveResourceServiceEnvironment = DynamicLibrary.open('RESUTILS.dll')
    .lookupFunction<ResUtilRemoveResourceServiceEnvironmentNative, ResUtilRemoveResourceServiceEnvironmentDart>('ResUtilRemoveResourceServiceEnvironment');
// pszServiceName : LPCWSTR -> Pointer<Utf16>
// pfnLogEvent : PLOG_EVENT_ROUTINE -> Pointer<Void>
// hResourceHandle : INT_PTR -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ResUtilRemoveResourceServiceEnvironment(
  pszServiceName: PWideChar;   // LPCWSTR
  pfnLogEvent: Pointer;   // PLOG_EVENT_ROUTINE
  hResourceHandle: NativeInt   // INT_PTR
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilRemoveResourceServiceEnvironment';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ResUtilRemoveResourceServiceEnvironment"
  c_ResUtilRemoveResourceServiceEnvironment :: CWString -> Ptr () -> CIntPtr -> IO Word32
-- pszServiceName : LPCWSTR -> CWString
-- pfnLogEvent : PLOG_EVENT_ROUTINE -> Ptr ()
-- hResourceHandle : INT_PTR -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let resutilremoveresourceserviceenvironment =
  foreign "ResUtilRemoveResourceServiceEnvironment"
    ((ptr uint16_t) @-> (ptr void) @-> intptr_t @-> returning uint32_t)
(* pszServiceName : LPCWSTR -> (ptr uint16_t) *)
(* pfnLogEvent : PLOG_EVENT_ROUTINE -> (ptr void) *)
(* hResourceHandle : INT_PTR -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)

(cffi:defcfun ("ResUtilRemoveResourceServiceEnvironment" res-util-remove-resource-service-environment :convention :stdcall) :uint32
  (psz-service-name (:string :encoding :utf-16le))   ; LPCWSTR
  (pfn-log-event :pointer)   ; PLOG_EVENT_ROUTINE
  (h-resource-handle :int64))   ; INT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilRemoveResourceServiceEnvironment = Win32::API::More->new('RESUTILS',
    'DWORD ResUtilRemoveResourceServiceEnvironment(LPCWSTR pszServiceName, LPVOID pfnLogEvent, LPARAM hResourceHandle)');
# my $ret = $ResUtilRemoveResourceServiceEnvironment->Call($pszServiceName, $pfnLogEvent, $hResourceHandle);
# pszServiceName : LPCWSTR -> LPCWSTR
# pfnLogEvent : PLOG_EVENT_ROUTINE -> LPVOID
# hResourceHandle : INT_PTR -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型