Win32 API 日本語リファレンス
ホームSystem.Services › QueryServiceDynamicInformation

QueryServiceDynamicInformation

関数
実行中サービスの動的な情報を取得する。
DLLADVAPI32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

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

BOOL QueryServiceDynamicInformation(
    SERVICE_STATUS_HANDLE hServiceStatus,
    DWORD dwInfoLevel,
    void** ppDynamicInfo
);

パラメーター

名前方向
hServiceStatusSERVICE_STATUS_HANDLEin
dwInfoLevelDWORDin
ppDynamicInfovoid**out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL QueryServiceDynamicInformation(
    SERVICE_STATUS_HANDLE hServiceStatus,
    DWORD dwInfoLevel,
    void** ppDynamicInfo
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool QueryServiceDynamicInformation(
    IntPtr hServiceStatus,   // SERVICE_STATUS_HANDLE
    uint dwInfoLevel,   // DWORD
    IntPtr ppDynamicInfo   // void** out
);
<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function QueryServiceDynamicInformation(
    hServiceStatus As IntPtr,   ' SERVICE_STATUS_HANDLE
    dwInfoLevel As UInteger,   ' DWORD
    ppDynamicInfo As IntPtr   ' void** out
) As Boolean
End Function
' hServiceStatus : SERVICE_STATUS_HANDLE
' dwInfoLevel : DWORD
' ppDynamicInfo : void** out
Declare PtrSafe Function QueryServiceDynamicInformation Lib "advapi32" ( _
    ByVal hServiceStatus As LongPtr, _
    ByVal dwInfoLevel As Long, _
    ByVal ppDynamicInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

QueryServiceDynamicInformation = ctypes.windll.advapi32.QueryServiceDynamicInformation
QueryServiceDynamicInformation.restype = wintypes.BOOL
QueryServiceDynamicInformation.argtypes = [
    wintypes.HANDLE,  # hServiceStatus : SERVICE_STATUS_HANDLE
    wintypes.DWORD,  # dwInfoLevel : DWORD
    ctypes.c_void_p,  # ppDynamicInfo : void** out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
QueryServiceDynamicInformation = Fiddle::Function.new(
  lib['QueryServiceDynamicInformation'],
  [
    Fiddle::TYPE_VOIDP,  # hServiceStatus : SERVICE_STATUS_HANDLE
    -Fiddle::TYPE_INT,  # dwInfoLevel : DWORD
    Fiddle::TYPE_VOIDP,  # ppDynamicInfo : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn QueryServiceDynamicInformation(
        hServiceStatus: *mut core::ffi::c_void,  // SERVICE_STATUS_HANDLE
        dwInfoLevel: u32,  // DWORD
        ppDynamicInfo: *mut *mut ()  // void** out
    ) -> 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 QueryServiceDynamicInformation(IntPtr hServiceStatus, uint dwInfoLevel, IntPtr ppDynamicInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_QueryServiceDynamicInformation' -Namespace Win32 -PassThru
# $api::QueryServiceDynamicInformation(hServiceStatus, dwInfoLevel, ppDynamicInfo)
#uselib "ADVAPI32.dll"
#func global QueryServiceDynamicInformation "QueryServiceDynamicInformation" sptr, sptr, sptr
; QueryServiceDynamicInformation hServiceStatus, dwInfoLevel, ppDynamicInfo   ; 戻り値は stat
; hServiceStatus : SERVICE_STATUS_HANDLE -> "sptr"
; dwInfoLevel : DWORD -> "sptr"
; ppDynamicInfo : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVAPI32.dll"
#cfunc global QueryServiceDynamicInformation "QueryServiceDynamicInformation" sptr, int, sptr
; res = QueryServiceDynamicInformation(hServiceStatus, dwInfoLevel, ppDynamicInfo)
; hServiceStatus : SERVICE_STATUS_HANDLE -> "sptr"
; dwInfoLevel : DWORD -> "int"
; ppDynamicInfo : void** out -> "sptr"
; BOOL QueryServiceDynamicInformation(SERVICE_STATUS_HANDLE hServiceStatus, DWORD dwInfoLevel, void** ppDynamicInfo)
#uselib "ADVAPI32.dll"
#cfunc global QueryServiceDynamicInformation "QueryServiceDynamicInformation" intptr, int, intptr
; res = QueryServiceDynamicInformation(hServiceStatus, dwInfoLevel, ppDynamicInfo)
; hServiceStatus : SERVICE_STATUS_HANDLE -> "intptr"
; dwInfoLevel : DWORD -> "int"
; ppDynamicInfo : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procQueryServiceDynamicInformation = advapi32.NewProc("QueryServiceDynamicInformation")
)

// hServiceStatus (SERVICE_STATUS_HANDLE), dwInfoLevel (DWORD), ppDynamicInfo (void** out)
r1, _, err := procQueryServiceDynamicInformation.Call(
	uintptr(hServiceStatus),
	uintptr(dwInfoLevel),
	uintptr(ppDynamicInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function QueryServiceDynamicInformation(
  hServiceStatus: THandle;   // SERVICE_STATUS_HANDLE
  dwInfoLevel: DWORD;   // DWORD
  ppDynamicInfo: Pointer   // void** out
): BOOL; stdcall;
  external 'ADVAPI32.dll' name 'QueryServiceDynamicInformation';
result := DllCall("ADVAPI32\QueryServiceDynamicInformation"
    , "Ptr", hServiceStatus   ; SERVICE_STATUS_HANDLE
    , "UInt", dwInfoLevel   ; DWORD
    , "Ptr", ppDynamicInfo   ; void** out
    , "Int")   ; return: BOOL
●QueryServiceDynamicInformation(hServiceStatus, dwInfoLevel, ppDynamicInfo) = DLL("ADVAPI32.dll", "bool QueryServiceDynamicInformation(void*, dword, void*)")
# 呼び出し: QueryServiceDynamicInformation(hServiceStatus, dwInfoLevel, ppDynamicInfo)
# hServiceStatus : SERVICE_STATUS_HANDLE -> "void*"
# dwInfoLevel : DWORD -> "dword"
# ppDynamicInfo : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。