Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › SLGetServiceInformation

SLGetServiceInformation

関数
ライセンスサービスに関する情報の値を取得する。
DLLSLC.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT SLGetServiceInformation(
    void* hSLC,
    LPCWSTR pwszValueName,
    SLDATATYPE* peDataType,   // optional
    DWORD* pcbValue,
    BYTE** ppbValue
);

パラメーター

名前方向説明
hSLCvoid*inSLOpenで取得したSLCハンドル。
pwszValueNameLPCWSTRin取得するサービス情報値の名前を指すUnicode文字列。
peDataTypeSLDATATYPE*outoptional返される値のデータ型を受け取るSLDATATYPE列挙値へのポインタ。NULL可。
pcbValueDWORD*outppbValueに格納されたデータのバイト長を受け取るDWORDへのポインタ。
ppbValueBYTE**out取得した値のバイト列を受け取るポインタ。解放が必要。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SLGetServiceInformation(
    void* hSLC,
    LPCWSTR pwszValueName,
    SLDATATYPE* peDataType,   // optional
    DWORD* pcbValue,
    BYTE** ppbValue
);
[DllImport("SLC.dll", ExactSpelling = true)]
static extern int SLGetServiceInformation(
    IntPtr hSLC,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string pwszValueName,   // LPCWSTR
    IntPtr peDataType,   // SLDATATYPE* optional, out
    out uint pcbValue,   // DWORD* out
    IntPtr ppbValue   // BYTE** out
);
<DllImport("SLC.dll", ExactSpelling:=True)>
Public Shared Function SLGetServiceInformation(
    hSLC As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> pwszValueName As String,   ' LPCWSTR
    peDataType As IntPtr,   ' SLDATATYPE* optional, out
    <Out> ByRef pcbValue As UInteger,   ' DWORD* out
    ppbValue As IntPtr   ' BYTE** out
) As Integer
End Function
' hSLC : void*
' pwszValueName : LPCWSTR
' peDataType : SLDATATYPE* optional, out
' pcbValue : DWORD* out
' ppbValue : BYTE** out
Declare PtrSafe Function SLGetServiceInformation Lib "slc" ( _
    ByVal hSLC As LongPtr, _
    ByVal pwszValueName As LongPtr, _
    ByVal peDataType As LongPtr, _
    ByRef pcbValue As Long, _
    ByVal ppbValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SLGetServiceInformation = ctypes.windll.slc.SLGetServiceInformation
SLGetServiceInformation.restype = ctypes.c_int
SLGetServiceInformation.argtypes = [
    ctypes.POINTER(None),  # hSLC : void*
    wintypes.LPCWSTR,  # pwszValueName : LPCWSTR
    ctypes.c_void_p,  # peDataType : SLDATATYPE* optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcbValue : DWORD* out
    ctypes.c_void_p,  # ppbValue : BYTE** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SLC.dll')
SLGetServiceInformation = Fiddle::Function.new(
  lib['SLGetServiceInformation'],
  [
    Fiddle::TYPE_VOIDP,  # hSLC : void*
    Fiddle::TYPE_VOIDP,  # pwszValueName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # peDataType : SLDATATYPE* optional, out
    Fiddle::TYPE_VOIDP,  # pcbValue : DWORD* out
    Fiddle::TYPE_VOIDP,  # ppbValue : BYTE** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "slc")]
extern "system" {
    fn SLGetServiceInformation(
        hSLC: *mut (),  // void*
        pwszValueName: *const u16,  // LPCWSTR
        peDataType: *mut u32,  // SLDATATYPE* optional, out
        pcbValue: *mut u32,  // DWORD* out
        ppbValue: *mut *mut u8  // BYTE** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SLC.dll")]
public static extern int SLGetServiceInformation(IntPtr hSLC, [MarshalAs(UnmanagedType.LPWStr)] string pwszValueName, IntPtr peDataType, out uint pcbValue, IntPtr ppbValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SLC_SLGetServiceInformation' -Namespace Win32 -PassThru
# $api::SLGetServiceInformation(hSLC, pwszValueName, peDataType, pcbValue, ppbValue)
#uselib "SLC.dll"
#func global SLGetServiceInformation "SLGetServiceInformation" sptr, sptr, sptr, sptr, sptr
; SLGetServiceInformation hSLC, pwszValueName, varptr(peDataType), varptr(pcbValue), varptr(ppbValue)   ; 戻り値は stat
; hSLC : void* -> "sptr"
; pwszValueName : LPCWSTR -> "sptr"
; peDataType : SLDATATYPE* optional, out -> "sptr"
; pcbValue : DWORD* out -> "sptr"
; ppbValue : BYTE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SLC.dll"
#cfunc global SLGetServiceInformation "SLGetServiceInformation" sptr, wstr, var, var, var
; res = SLGetServiceInformation(hSLC, pwszValueName, peDataType, pcbValue, ppbValue)
; hSLC : void* -> "sptr"
; pwszValueName : LPCWSTR -> "wstr"
; peDataType : SLDATATYPE* optional, out -> "var"
; pcbValue : DWORD* out -> "var"
; ppbValue : BYTE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT SLGetServiceInformation(void* hSLC, LPCWSTR pwszValueName, SLDATATYPE* peDataType, DWORD* pcbValue, BYTE** ppbValue)
#uselib "SLC.dll"
#cfunc global SLGetServiceInformation "SLGetServiceInformation" intptr, wstr, var, var, var
; res = SLGetServiceInformation(hSLC, pwszValueName, peDataType, pcbValue, ppbValue)
; hSLC : void* -> "intptr"
; pwszValueName : LPCWSTR -> "wstr"
; peDataType : SLDATATYPE* optional, out -> "var"
; pcbValue : DWORD* out -> "var"
; ppbValue : BYTE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	slc = windows.NewLazySystemDLL("SLC.dll")
	procSLGetServiceInformation = slc.NewProc("SLGetServiceInformation")
)

// hSLC (void*), pwszValueName (LPCWSTR), peDataType (SLDATATYPE* optional, out), pcbValue (DWORD* out), ppbValue (BYTE** out)
r1, _, err := procSLGetServiceInformation.Call(
	uintptr(hSLC),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszValueName))),
	uintptr(peDataType),
	uintptr(pcbValue),
	uintptr(ppbValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SLGetServiceInformation(
  hSLC: Pointer;   // void*
  pwszValueName: PWideChar;   // LPCWSTR
  peDataType: Pointer;   // SLDATATYPE* optional, out
  pcbValue: Pointer;   // DWORD* out
  ppbValue: Pointer   // BYTE** out
): Integer; stdcall;
  external 'SLC.dll' name 'SLGetServiceInformation';
result := DllCall("SLC\SLGetServiceInformation"
    , "Ptr", hSLC   ; void*
    , "WStr", pwszValueName   ; LPCWSTR
    , "Ptr", peDataType   ; SLDATATYPE* optional, out
    , "Ptr", pcbValue   ; DWORD* out
    , "Ptr", ppbValue   ; BYTE** out
    , "Int")   ; return: HRESULT
●SLGetServiceInformation(hSLC, pwszValueName, peDataType, pcbValue, ppbValue) = DLL("SLC.dll", "int SLGetServiceInformation(void*, char*, void*, void*, void*)")
# 呼び出し: SLGetServiceInformation(hSLC, pwszValueName, peDataType, pcbValue, ppbValue)
# hSLC : void* -> "void*"
# pwszValueName : LPCWSTR -> "char*"
# peDataType : SLDATATYPE* optional, out -> "void*"
# pcbValue : DWORD* out -> "void*"
# ppbValue : BYTE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef SLGetServiceInformationNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Uint32>, Pointer<Uint8>);
typedef SLGetServiceInformationDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Uint32>, Pointer<Uint8>);
final SLGetServiceInformation = DynamicLibrary.open('SLC.dll')
    .lookupFunction<SLGetServiceInformationNative, SLGetServiceInformationDart>('SLGetServiceInformation');
// hSLC : void* -> Pointer<Void>
// pwszValueName : LPCWSTR -> Pointer<Utf16>
// peDataType : SLDATATYPE* optional, out -> Pointer<Uint32>
// pcbValue : DWORD* out -> Pointer<Uint32>
// ppbValue : BYTE** out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SLGetServiceInformation(
  hSLC: Pointer;   // void*
  pwszValueName: PWideChar;   // LPCWSTR
  peDataType: Pointer;   // SLDATATYPE* optional, out
  pcbValue: Pointer;   // DWORD* out
  ppbValue: Pointer   // BYTE** out
): Integer; stdcall;
  external 'SLC.dll' name 'SLGetServiceInformation';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SLGetServiceInformation"
  c_SLGetServiceInformation :: Ptr () -> CWString -> Ptr Word32 -> Ptr Word32 -> Ptr Word8 -> IO Int32
-- hSLC : void* -> Ptr ()
-- pwszValueName : LPCWSTR -> CWString
-- peDataType : SLDATATYPE* optional, out -> Ptr Word32
-- pcbValue : DWORD* out -> Ptr Word32
-- ppbValue : BYTE** out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let slgetserviceinformation =
  foreign "SLGetServiceInformation"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr uint32_t) @-> (ptr uint8_t) @-> returning int32_t)
(* hSLC : void* -> (ptr void) *)
(* pwszValueName : LPCWSTR -> (ptr uint16_t) *)
(* peDataType : SLDATATYPE* optional, out -> (ptr uint32_t) *)
(* pcbValue : DWORD* out -> (ptr uint32_t) *)
(* ppbValue : BYTE** out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library slc (t "SLC.dll"))
(cffi:use-foreign-library slc)

(cffi:defcfun ("SLGetServiceInformation" slget-service-information :convention :stdcall) :int32
  (h-slc :pointer)   ; void*
  (pwsz-value-name (:string :encoding :utf-16le))   ; LPCWSTR
  (pe-data-type :pointer)   ; SLDATATYPE* optional, out
  (pcb-value :pointer)   ; DWORD* out
  (ppb-value :pointer))   ; BYTE** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SLGetServiceInformation = Win32::API::More->new('SLC',
    'int SLGetServiceInformation(LPVOID hSLC, LPCWSTR pwszValueName, LPVOID peDataType, LPVOID pcbValue, LPVOID ppbValue)');
# my $ret = $SLGetServiceInformation->Call($hSLC, $pwszValueName, $peDataType, $pcbValue, $ppbValue);
# hSLC : void* -> LPVOID
# pwszValueName : LPCWSTR -> LPCWSTR
# peDataType : SLDATATYPE* optional, out -> LPVOID
# pcbValue : DWORD* out -> LPVOID
# ppbValue : BYTE** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型