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

ResUtilStopResourceService

関数
指定したリソースのサービスを停止する。
DLLRESUTILS.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD ResUtilStopResourceService(
    LPCWSTR pszServiceName
);

パラメーター

名前方向説明
pszServiceNameLPCWSTRin停止するサービスの名前を示すワイド文字列。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

ResUtilStopResourceService = ctypes.windll.resutils.ResUtilStopResourceService
ResUtilStopResourceService.restype = wintypes.DWORD
ResUtilStopResourceService.argtypes = [
    wintypes.LPCWSTR,  # pszServiceName : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilStopResourceService = resutils.NewProc("ResUtilStopResourceService")
)

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

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

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

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

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

(cffi:defcfun ("ResUtilStopResourceService" res-util-stop-resource-service :convention :stdcall) :uint32
  (psz-service-name (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilStopResourceService = Win32::API::More->new('RESUTILS',
    'DWORD ResUtilStopResourceService(LPCWSTR pszServiceName)');
# my $ret = $ResUtilStopResourceService->Call($pszServiceName);
# pszServiceName : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。