ホーム › Networking.Clustering › ResUtilStartResourceService
ResUtilStartResourceService
関数指定したリソースのサービスを開始する。
シグネチャ
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilStartResourceService(
LPCWSTR pszServiceName,
SC_HANDLE* phServiceHandle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszServiceName | LPCWSTR | in | 開始するサービスの名前を示すワイド文字列。 |
| phServiceHandle | SC_HANDLE* | inout | 開いたサービスのハンドルを受け取るSC_HANDLEポインタ。NULL可。 |
戻り値の型: DWORD
各言語での呼び出し定義
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilStartResourceService(
LPCWSTR pszServiceName,
SC_HANDLE* phServiceHandle
);[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilStartResourceService(
[MarshalAs(UnmanagedType.LPWStr)] string pszServiceName, // LPCWSTR
IntPtr phServiceHandle // SC_HANDLE* in/out
);<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilStartResourceService(
<MarshalAs(UnmanagedType.LPWStr)> pszServiceName As String, ' LPCWSTR
phServiceHandle As IntPtr ' SC_HANDLE* in/out
) As UInteger
End Function' pszServiceName : LPCWSTR
' phServiceHandle : SC_HANDLE* in/out
Declare PtrSafe Function ResUtilStartResourceService Lib "resutils" ( _
ByVal pszServiceName As LongPtr, _
ByVal phServiceHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ResUtilStartResourceService = ctypes.windll.resutils.ResUtilStartResourceService
ResUtilStartResourceService.restype = wintypes.DWORD
ResUtilStartResourceService.argtypes = [
wintypes.LPCWSTR, # pszServiceName : LPCWSTR
ctypes.c_void_p, # phServiceHandle : SC_HANDLE* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilStartResourceService = Fiddle::Function.new(
lib['ResUtilStartResourceService'],
[
Fiddle::TYPE_VOIDP, # pszServiceName : LPCWSTR
Fiddle::TYPE_VOIDP, # phServiceHandle : SC_HANDLE* in/out
],
-Fiddle::TYPE_INT)#[link(name = "resutils")]
extern "system" {
fn ResUtilStartResourceService(
pszServiceName: *const u16, // LPCWSTR
phServiceHandle: *mut *mut core::ffi::c_void // SC_HANDLE* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilStartResourceService([MarshalAs(UnmanagedType.LPWStr)] string pszServiceName, IntPtr phServiceHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilStartResourceService' -Namespace Win32 -PassThru
# $api::ResUtilStartResourceService(pszServiceName, phServiceHandle)#uselib "RESUTILS.dll"
#func global ResUtilStartResourceService "ResUtilStartResourceService" sptr, sptr
; ResUtilStartResourceService pszServiceName, phServiceHandle ; 戻り値は stat
; pszServiceName : LPCWSTR -> "sptr"
; phServiceHandle : SC_HANDLE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RESUTILS.dll"
#cfunc global ResUtilStartResourceService "ResUtilStartResourceService" wstr, sptr
; res = ResUtilStartResourceService(pszServiceName, phServiceHandle)
; pszServiceName : LPCWSTR -> "wstr"
; phServiceHandle : SC_HANDLE* in/out -> "sptr"; DWORD ResUtilStartResourceService(LPCWSTR pszServiceName, SC_HANDLE* phServiceHandle)
#uselib "RESUTILS.dll"
#cfunc global ResUtilStartResourceService "ResUtilStartResourceService" wstr, intptr
; res = ResUtilStartResourceService(pszServiceName, phServiceHandle)
; pszServiceName : LPCWSTR -> "wstr"
; phServiceHandle : SC_HANDLE* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
resutils = windows.NewLazySystemDLL("RESUTILS.dll")
procResUtilStartResourceService = resutils.NewProc("ResUtilStartResourceService")
)
// pszServiceName (LPCWSTR), phServiceHandle (SC_HANDLE* in/out)
r1, _, err := procResUtilStartResourceService.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszServiceName))),
uintptr(phServiceHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ResUtilStartResourceService(
pszServiceName: PWideChar; // LPCWSTR
phServiceHandle: Pointer // SC_HANDLE* in/out
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilStartResourceService';result := DllCall("RESUTILS\ResUtilStartResourceService"
, "WStr", pszServiceName ; LPCWSTR
, "Ptr", phServiceHandle ; SC_HANDLE* in/out
, "UInt") ; return: DWORD●ResUtilStartResourceService(pszServiceName, phServiceHandle) = DLL("RESUTILS.dll", "dword ResUtilStartResourceService(char*, void*)")
# 呼び出し: ResUtilStartResourceService(pszServiceName, phServiceHandle)
# pszServiceName : LPCWSTR -> "char*"
# phServiceHandle : SC_HANDLE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "resutils" fn ResUtilStartResourceService(
pszServiceName: [*c]const u16, // LPCWSTR
phServiceHandle: ?*anyopaque // SC_HANDLE* in/out
) callconv(std.os.windows.WINAPI) u32;proc ResUtilStartResourceService(
pszServiceName: WideCString, # LPCWSTR
phServiceHandle: pointer # SC_HANDLE* in/out
): uint32 {.importc: "ResUtilStartResourceService", stdcall, dynlib: "RESUTILS.dll".}pragma(lib, "resutils");
extern(Windows)
uint ResUtilStartResourceService(
const(wchar)* pszServiceName, // LPCWSTR
void* phServiceHandle // SC_HANDLE* in/out
);ccall((:ResUtilStartResourceService, "RESUTILS.dll"), stdcall, UInt32,
(Cwstring, Ptr{Cvoid}),
pszServiceName, phServiceHandle)
# pszServiceName : LPCWSTR -> Cwstring
# phServiceHandle : SC_HANDLE* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilStartResourceService(
const uint16_t* pszServiceName,
void* phServiceHandle);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilStartResourceService(pszServiceName, phServiceHandle)
-- pszServiceName : LPCWSTR
-- phServiceHandle : SC_HANDLE* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilStartResourceService = lib.func('__stdcall', 'ResUtilStartResourceService', 'uint32_t', ['str16', 'void *']);
// ResUtilStartResourceService(pszServiceName, phServiceHandle)
// pszServiceName : LPCWSTR -> 'str16'
// phServiceHandle : SC_HANDLE* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RESUTILS.dll", {
ResUtilStartResourceService: { parameters: ["buffer", "pointer"], result: "u32" },
});
// lib.symbols.ResUtilStartResourceService(pszServiceName, phServiceHandle)
// pszServiceName : LPCWSTR -> "buffer"
// phServiceHandle : SC_HANDLE* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilStartResourceService(
const uint16_t* pszServiceName,
void* phServiceHandle);
C, "RESUTILS.dll");
// $ffi->ResUtilStartResourceService(pszServiceName, phServiceHandle);
// pszServiceName : LPCWSTR
// phServiceHandle : SC_HANDLE* in/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 Resutils extends StdCallLibrary {
Resutils INSTANCE = Native.load("resutils", Resutils.class);
int ResUtilStartResourceService(
WString pszServiceName, // LPCWSTR
Pointer phServiceHandle // SC_HANDLE* in/out
);
}@[Link("resutils")]
lib LibRESUTILS
fun ResUtilStartResourceService = ResUtilStartResourceService(
pszServiceName : UInt16*, # LPCWSTR
phServiceHandle : Void* # SC_HANDLE* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ResUtilStartResourceServiceNative = Uint32 Function(Pointer<Utf16>, Pointer<Void>);
typedef ResUtilStartResourceServiceDart = int Function(Pointer<Utf16>, Pointer<Void>);
final ResUtilStartResourceService = DynamicLibrary.open('RESUTILS.dll')
.lookupFunction<ResUtilStartResourceServiceNative, ResUtilStartResourceServiceDart>('ResUtilStartResourceService');
// pszServiceName : LPCWSTR -> Pointer<Utf16>
// phServiceHandle : SC_HANDLE* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ResUtilStartResourceService(
pszServiceName: PWideChar; // LPCWSTR
phServiceHandle: Pointer // SC_HANDLE* in/out
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilStartResourceService';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ResUtilStartResourceService"
c_ResUtilStartResourceService :: CWString -> Ptr () -> IO Word32
-- pszServiceName : LPCWSTR -> CWString
-- phServiceHandle : SC_HANDLE* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let resutilstartresourceservice =
foreign "ResUtilStartResourceService"
((ptr uint16_t) @-> (ptr void) @-> returning uint32_t)
(* pszServiceName : LPCWSTR -> (ptr uint16_t) *)
(* phServiceHandle : SC_HANDLE* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)
(cffi:defcfun ("ResUtilStartResourceService" res-util-start-resource-service :convention :stdcall) :uint32
(psz-service-name (:string :encoding :utf-16le)) ; LPCWSTR
(ph-service-handle :pointer)) ; SC_HANDLE* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ResUtilStartResourceService = Win32::API::More->new('RESUTILS',
'DWORD ResUtilStartResourceService(LPCWSTR pszServiceName, HANDLE phServiceHandle)');
# my $ret = $ResUtilStartResourceService->Call($pszServiceName, $phServiceHandle);
# pszServiceName : LPCWSTR -> LPCWSTR
# phServiceHandle : SC_HANDLE* in/out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。