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