ホーム › System.Services › DeleteService
DeleteService
関数指定したサービスをSCMデータベースから削除する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL DeleteService(
SC_HANDLE hService
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hService | SC_HANDLE | in |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL DeleteService(
SC_HANDLE hService
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool DeleteService(
IntPtr hService // SC_HANDLE
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DeleteService(
hService As IntPtr ' SC_HANDLE
) As Boolean
End Function' hService : SC_HANDLE
Declare PtrSafe Function DeleteService Lib "advapi32" ( _
ByVal hService As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DeleteService = ctypes.windll.advapi32.DeleteService
DeleteService.restype = wintypes.BOOL
DeleteService.argtypes = [
wintypes.HANDLE, # hService : SC_HANDLE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
DeleteService = Fiddle::Function.new(
lib['DeleteService'],
[
Fiddle::TYPE_VOIDP, # hService : SC_HANDLE
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn DeleteService(
hService: *mut core::ffi::c_void // SC_HANDLE
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true)]
public static extern bool DeleteService(IntPtr hService);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_DeleteService' -Namespace Win32 -PassThru
# $api::DeleteService(hService)#uselib "ADVAPI32.dll"
#func global DeleteService "DeleteService" sptr
; DeleteService hService ; 戻り値は stat
; hService : SC_HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global DeleteService "DeleteService" sptr
; res = DeleteService(hService)
; hService : SC_HANDLE -> "sptr"; BOOL DeleteService(SC_HANDLE hService)
#uselib "ADVAPI32.dll"
#cfunc global DeleteService "DeleteService" intptr
; res = DeleteService(hService)
; hService : SC_HANDLE -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procDeleteService = advapi32.NewProc("DeleteService")
)
// hService (SC_HANDLE)
r1, _, err := procDeleteService.Call(
uintptr(hService),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DeleteService(
hService: THandle // SC_HANDLE
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'DeleteService';result := DllCall("ADVAPI32\DeleteService"
, "Ptr", hService ; SC_HANDLE
, "Int") ; return: BOOL●DeleteService(hService) = DLL("ADVAPI32.dll", "bool DeleteService(void*)")
# 呼び出し: DeleteService(hService)
# hService : SC_HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。