ホーム › Security.Authentication.Identity › SLGetPolicyInformation
SLGetPolicyInformation
関数ライセンスポリシーの指定値を取得する。
シグネチャ
// SLC.dll
#include <windows.h>
HRESULT SLGetPolicyInformation(
void* hSLC,
LPCWSTR pwszValueName,
SLDATATYPE* peDataType, // optional
DWORD* pcbValue,
BYTE** ppbValue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hSLC | void* | in | SLOpenで取得したSLCハンドル。 |
| pwszValueName | LPCWSTR | in | 取得するポリシー値の名前を指すUnicode文字列。 |
| peDataType | SLDATATYPE* | outoptional | 返される値のデータ型を受け取るSLDATATYPE列挙値へのポインタ。NULL可。 |
| pcbValue | DWORD* | out | ppbValueに格納されたデータのバイト長を受け取るDWORDへのポインタ。 |
| ppbValue | BYTE** | out | 取得したポリシー値のバイト列を受け取るポインタ。解放が必要。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// SLC.dll
#include <windows.h>
HRESULT SLGetPolicyInformation(
void* hSLC,
LPCWSTR pwszValueName,
SLDATATYPE* peDataType, // optional
DWORD* pcbValue,
BYTE** ppbValue
);[DllImport("SLC.dll", ExactSpelling = true)]
static extern int SLGetPolicyInformation(
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 SLGetPolicyInformation(
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 SLGetPolicyInformation 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
SLGetPolicyInformation = ctypes.windll.slc.SLGetPolicyInformation
SLGetPolicyInformation.restype = ctypes.c_int
SLGetPolicyInformation.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')
SLGetPolicyInformation = Fiddle::Function.new(
lib['SLGetPolicyInformation'],
[
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 SLGetPolicyInformation(
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 SLGetPolicyInformation(IntPtr hSLC, [MarshalAs(UnmanagedType.LPWStr)] string pwszValueName, IntPtr peDataType, out uint pcbValue, IntPtr ppbValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SLC_SLGetPolicyInformation' -Namespace Win32 -PassThru
# $api::SLGetPolicyInformation(hSLC, pwszValueName, peDataType, pcbValue, ppbValue)#uselib "SLC.dll"
#func global SLGetPolicyInformation "SLGetPolicyInformation" sptr, sptr, sptr, sptr, sptr
; SLGetPolicyInformation 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 SLGetPolicyInformation "SLGetPolicyInformation" sptr, wstr, var, var, var ; res = SLGetPolicyInformation(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 方式にも切替可。#uselib "SLC.dll" #cfunc global SLGetPolicyInformation "SLGetPolicyInformation" sptr, wstr, sptr, sptr, sptr ; res = SLGetPolicyInformation(hSLC, pwszValueName, varptr(peDataType), varptr(pcbValue), varptr(ppbValue)) ; hSLC : void* -> "sptr" ; pwszValueName : LPCWSTR -> "wstr" ; peDataType : SLDATATYPE* optional, out -> "sptr" ; pcbValue : DWORD* out -> "sptr" ; ppbValue : BYTE** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SLGetPolicyInformation(void* hSLC, LPCWSTR pwszValueName, SLDATATYPE* peDataType, DWORD* pcbValue, BYTE** ppbValue) #uselib "SLC.dll" #cfunc global SLGetPolicyInformation "SLGetPolicyInformation" intptr, wstr, var, var, var ; res = SLGetPolicyInformation(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 方式にも切替可。; HRESULT SLGetPolicyInformation(void* hSLC, LPCWSTR pwszValueName, SLDATATYPE* peDataType, DWORD* pcbValue, BYTE** ppbValue) #uselib "SLC.dll" #cfunc global SLGetPolicyInformation "SLGetPolicyInformation" intptr, wstr, intptr, intptr, intptr ; res = SLGetPolicyInformation(hSLC, pwszValueName, varptr(peDataType), varptr(pcbValue), varptr(ppbValue)) ; hSLC : void* -> "intptr" ; pwszValueName : LPCWSTR -> "wstr" ; peDataType : SLDATATYPE* optional, out -> "intptr" ; pcbValue : DWORD* out -> "intptr" ; ppbValue : BYTE** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
slc = windows.NewLazySystemDLL("SLC.dll")
procSLGetPolicyInformation = slc.NewProc("SLGetPolicyInformation")
)
// hSLC (void*), pwszValueName (LPCWSTR), peDataType (SLDATATYPE* optional, out), pcbValue (DWORD* out), ppbValue (BYTE** out)
r1, _, err := procSLGetPolicyInformation.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 // HRESULTfunction SLGetPolicyInformation(
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 'SLGetPolicyInformation';result := DllCall("SLC\SLGetPolicyInformation"
, "Ptr", hSLC ; void*
, "WStr", pwszValueName ; LPCWSTR
, "Ptr", peDataType ; SLDATATYPE* optional, out
, "Ptr", pcbValue ; DWORD* out
, "Ptr", ppbValue ; BYTE** out
, "Int") ; return: HRESULT●SLGetPolicyInformation(hSLC, pwszValueName, peDataType, pcbValue, ppbValue) = DLL("SLC.dll", "int SLGetPolicyInformation(void*, char*, void*, void*, void*)")
# 呼び出し: SLGetPolicyInformation(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 SLGetPolicyInformation(
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 SLGetPolicyInformation(
hSLC: pointer, # void*
pwszValueName: WideCString, # LPCWSTR
peDataType: ptr uint32, # SLDATATYPE* optional, out
pcbValue: ptr uint32, # DWORD* out
ppbValue: ptr uint8 # BYTE** out
): int32 {.importc: "SLGetPolicyInformation", stdcall, dynlib: "SLC.dll".}pragma(lib, "slc");
extern(Windows)
int SLGetPolicyInformation(
void* hSLC, // void*
const(wchar)* pwszValueName, // LPCWSTR
uint* peDataType, // SLDATATYPE* optional, out
uint* pcbValue, // DWORD* out
ubyte** ppbValue // BYTE** out
);ccall((:SLGetPolicyInformation, "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 SLGetPolicyInformation(
void* hSLC,
const uint16_t* pwszValueName,
uint32_t* peDataType,
uint32_t* pcbValue,
uint8_t** ppbValue);
]]
local slc = ffi.load("slc")
-- slc.SLGetPolicyInformation(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 SLGetPolicyInformation = lib.func('__stdcall', 'SLGetPolicyInformation', 'int32_t', ['void *', 'str16', 'uint32_t *', 'uint32_t *', 'uint8_t *']);
// SLGetPolicyInformation(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", {
SLGetPolicyInformation: { parameters: ["pointer", "buffer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SLGetPolicyInformation(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 SLGetPolicyInformation(
void* hSLC,
const uint16_t* pwszValueName,
uint32_t* peDataType,
uint32_t* pcbValue,
uint8_t** ppbValue);
C, "SLC.dll");
// $ffi->SLGetPolicyInformation(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 SLGetPolicyInformation(
Pointer hSLC, // void*
WString pwszValueName, // LPCWSTR
IntByReference peDataType, // SLDATATYPE* optional, out
IntByReference pcbValue, // DWORD* out
Pointer ppbValue // BYTE** out
);
}@[Link("slc")]
lib LibSLC
fun SLGetPolicyInformation = SLGetPolicyInformation(
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 SLGetPolicyInformationNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Uint32>, Pointer<Uint8>);
typedef SLGetPolicyInformationDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Uint32>, Pointer<Uint8>);
final SLGetPolicyInformation = DynamicLibrary.open('SLC.dll')
.lookupFunction<SLGetPolicyInformationNative, SLGetPolicyInformationDart>('SLGetPolicyInformation');
// 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 SLGetPolicyInformation(
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 'SLGetPolicyInformation';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SLGetPolicyInformation"
c_SLGetPolicyInformation :: 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 slgetpolicyinformation =
foreign "SLGetPolicyInformation"
((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 ("SLGetPolicyInformation" slget-policy-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 $SLGetPolicyInformation = Win32::API::More->new('SLC',
'int SLGetPolicyInformation(LPVOID hSLC, LPCWSTR pwszValueName, LPVOID peDataType, LPVOID pcbValue, LPVOID ppbValue)');
# my $ret = $SLGetPolicyInformation->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 を使用。関連項目
使用する型