ホーム › Security.Authentication.Identity › SLGetPolicyInformationDWORD
SLGetPolicyInformationDWORD
関数ライセンスポリシーの指定値をDWORD型で取得する。
シグネチャ
// SLC.dll
#include <windows.h>
HRESULT SLGetPolicyInformationDWORD(
void* hSLC,
LPCWSTR pwszValueName,
DWORD* pdwValue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hSLC | void* | in | SLOpenで取得したSLCハンドル。 |
| pwszValueName | LPCWSTR | in | 取得するDWORD型ポリシー値の名前を指すUnicode文字列。 |
| pdwValue | DWORD* | out | 取得したポリシー値(DWORD)を受け取るポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// SLC.dll
#include <windows.h>
HRESULT SLGetPolicyInformationDWORD(
void* hSLC,
LPCWSTR pwszValueName,
DWORD* pdwValue
);[DllImport("SLC.dll", ExactSpelling = true)]
static extern int SLGetPolicyInformationDWORD(
IntPtr hSLC, // void*
[MarshalAs(UnmanagedType.LPWStr)] string pwszValueName, // LPCWSTR
out uint pdwValue // DWORD* out
);<DllImport("SLC.dll", ExactSpelling:=True)>
Public Shared Function SLGetPolicyInformationDWORD(
hSLC As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> pwszValueName As String, ' LPCWSTR
<Out> ByRef pdwValue As UInteger ' DWORD* out
) As Integer
End Function' hSLC : void*
' pwszValueName : LPCWSTR
' pdwValue : DWORD* out
Declare PtrSafe Function SLGetPolicyInformationDWORD Lib "slc" ( _
ByVal hSLC As LongPtr, _
ByVal pwszValueName As LongPtr, _
ByRef pdwValue As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SLGetPolicyInformationDWORD = ctypes.windll.slc.SLGetPolicyInformationDWORD
SLGetPolicyInformationDWORD.restype = ctypes.c_int
SLGetPolicyInformationDWORD.argtypes = [
ctypes.POINTER(None), # hSLC : void*
wintypes.LPCWSTR, # pwszValueName : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # pdwValue : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SLC.dll')
SLGetPolicyInformationDWORD = Fiddle::Function.new(
lib['SLGetPolicyInformationDWORD'],
[
Fiddle::TYPE_VOIDP, # hSLC : void*
Fiddle::TYPE_VOIDP, # pwszValueName : LPCWSTR
Fiddle::TYPE_VOIDP, # pdwValue : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "slc")]
extern "system" {
fn SLGetPolicyInformationDWORD(
hSLC: *mut (), // void*
pwszValueName: *const u16, // LPCWSTR
pdwValue: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SLC.dll")]
public static extern int SLGetPolicyInformationDWORD(IntPtr hSLC, [MarshalAs(UnmanagedType.LPWStr)] string pwszValueName, out uint pdwValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SLC_SLGetPolicyInformationDWORD' -Namespace Win32 -PassThru
# $api::SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue)#uselib "SLC.dll"
#func global SLGetPolicyInformationDWORD "SLGetPolicyInformationDWORD" sptr, sptr, sptr
; SLGetPolicyInformationDWORD hSLC, pwszValueName, varptr(pdwValue) ; 戻り値は stat
; hSLC : void* -> "sptr"
; pwszValueName : LPCWSTR -> "sptr"
; pdwValue : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SLC.dll" #cfunc global SLGetPolicyInformationDWORD "SLGetPolicyInformationDWORD" sptr, wstr, var ; res = SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue) ; hSLC : void* -> "sptr" ; pwszValueName : LPCWSTR -> "wstr" ; pdwValue : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SLC.dll" #cfunc global SLGetPolicyInformationDWORD "SLGetPolicyInformationDWORD" sptr, wstr, sptr ; res = SLGetPolicyInformationDWORD(hSLC, pwszValueName, varptr(pdwValue)) ; hSLC : void* -> "sptr" ; pwszValueName : LPCWSTR -> "wstr" ; pdwValue : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SLGetPolicyInformationDWORD(void* hSLC, LPCWSTR pwszValueName, DWORD* pdwValue) #uselib "SLC.dll" #cfunc global SLGetPolicyInformationDWORD "SLGetPolicyInformationDWORD" intptr, wstr, var ; res = SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue) ; hSLC : void* -> "intptr" ; pwszValueName : LPCWSTR -> "wstr" ; pdwValue : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SLGetPolicyInformationDWORD(void* hSLC, LPCWSTR pwszValueName, DWORD* pdwValue) #uselib "SLC.dll" #cfunc global SLGetPolicyInformationDWORD "SLGetPolicyInformationDWORD" intptr, wstr, intptr ; res = SLGetPolicyInformationDWORD(hSLC, pwszValueName, varptr(pdwValue)) ; hSLC : void* -> "intptr" ; pwszValueName : LPCWSTR -> "wstr" ; pdwValue : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
slc = windows.NewLazySystemDLL("SLC.dll")
procSLGetPolicyInformationDWORD = slc.NewProc("SLGetPolicyInformationDWORD")
)
// hSLC (void*), pwszValueName (LPCWSTR), pdwValue (DWORD* out)
r1, _, err := procSLGetPolicyInformationDWORD.Call(
uintptr(hSLC),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszValueName))),
uintptr(pdwValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SLGetPolicyInformationDWORD(
hSLC: Pointer; // void*
pwszValueName: PWideChar; // LPCWSTR
pdwValue: Pointer // DWORD* out
): Integer; stdcall;
external 'SLC.dll' name 'SLGetPolicyInformationDWORD';result := DllCall("SLC\SLGetPolicyInformationDWORD"
, "Ptr", hSLC ; void*
, "WStr", pwszValueName ; LPCWSTR
, "Ptr", pdwValue ; DWORD* out
, "Int") ; return: HRESULT●SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue) = DLL("SLC.dll", "int SLGetPolicyInformationDWORD(void*, char*, void*)")
# 呼び出し: SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue)
# hSLC : void* -> "void*"
# pwszValueName : LPCWSTR -> "char*"
# pdwValue : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "slc" fn SLGetPolicyInformationDWORD(
hSLC: ?*anyopaque, // void*
pwszValueName: [*c]const u16, // LPCWSTR
pdwValue: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc SLGetPolicyInformationDWORD(
hSLC: pointer, # void*
pwszValueName: WideCString, # LPCWSTR
pdwValue: ptr uint32 # DWORD* out
): int32 {.importc: "SLGetPolicyInformationDWORD", stdcall, dynlib: "SLC.dll".}pragma(lib, "slc");
extern(Windows)
int SLGetPolicyInformationDWORD(
void* hSLC, // void*
const(wchar)* pwszValueName, // LPCWSTR
uint* pdwValue // DWORD* out
);ccall((:SLGetPolicyInformationDWORD, "SLC.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Ptr{UInt32}),
hSLC, pwszValueName, pdwValue)
# hSLC : void* -> Ptr{Cvoid}
# pwszValueName : LPCWSTR -> Cwstring
# pdwValue : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SLGetPolicyInformationDWORD(
void* hSLC,
const uint16_t* pwszValueName,
uint32_t* pdwValue);
]]
local slc = ffi.load("slc")
-- slc.SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue)
-- hSLC : void*
-- pwszValueName : LPCWSTR
-- pdwValue : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SLC.dll');
const SLGetPolicyInformationDWORD = lib.func('__stdcall', 'SLGetPolicyInformationDWORD', 'int32_t', ['void *', 'str16', 'uint32_t *']);
// SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue)
// hSLC : void* -> 'void *'
// pwszValueName : LPCWSTR -> 'str16'
// pdwValue : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SLC.dll", {
SLGetPolicyInformationDWORD: { parameters: ["pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue)
// hSLC : void* -> "pointer"
// pwszValueName : LPCWSTR -> "buffer"
// pdwValue : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SLGetPolicyInformationDWORD(
void* hSLC,
const uint16_t* pwszValueName,
uint32_t* pdwValue);
C, "SLC.dll");
// $ffi->SLGetPolicyInformationDWORD(hSLC, pwszValueName, pdwValue);
// hSLC : void*
// pwszValueName : LPCWSTR
// pdwValue : DWORD* 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 SLGetPolicyInformationDWORD(
Pointer hSLC, // void*
WString pwszValueName, // LPCWSTR
IntByReference pdwValue // DWORD* out
);
}@[Link("slc")]
lib LibSLC
fun SLGetPolicyInformationDWORD = SLGetPolicyInformationDWORD(
hSLC : Void*, # void*
pwszValueName : UInt16*, # LPCWSTR
pdwValue : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SLGetPolicyInformationDWORDNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>);
typedef SLGetPolicyInformationDWORDDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>);
final SLGetPolicyInformationDWORD = DynamicLibrary.open('SLC.dll')
.lookupFunction<SLGetPolicyInformationDWORDNative, SLGetPolicyInformationDWORDDart>('SLGetPolicyInformationDWORD');
// hSLC : void* -> Pointer<Void>
// pwszValueName : LPCWSTR -> Pointer<Utf16>
// pdwValue : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SLGetPolicyInformationDWORD(
hSLC: Pointer; // void*
pwszValueName: PWideChar; // LPCWSTR
pdwValue: Pointer // DWORD* out
): Integer; stdcall;
external 'SLC.dll' name 'SLGetPolicyInformationDWORD';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SLGetPolicyInformationDWORD"
c_SLGetPolicyInformationDWORD :: Ptr () -> CWString -> Ptr Word32 -> IO Int32
-- hSLC : void* -> Ptr ()
-- pwszValueName : LPCWSTR -> CWString
-- pdwValue : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let slgetpolicyinformationdword =
foreign "SLGetPolicyInformationDWORD"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* hSLC : void* -> (ptr void) *)
(* pwszValueName : LPCWSTR -> (ptr uint16_t) *)
(* pdwValue : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library slc (t "SLC.dll"))
(cffi:use-foreign-library slc)
(cffi:defcfun ("SLGetPolicyInformationDWORD" slget-policy-information-dword :convention :stdcall) :int32
(h-slc :pointer) ; void*
(pwsz-value-name (:string :encoding :utf-16le)) ; LPCWSTR
(pdw-value :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SLGetPolicyInformationDWORD = Win32::API::More->new('SLC',
'int SLGetPolicyInformationDWORD(LPVOID hSLC, LPCWSTR pwszValueName, LPVOID pdwValue)');
# my $ret = $SLGetPolicyInformationDWORD->Call($hSLC, $pwszValueName, $pdwValue);
# hSLC : void* -> LPVOID
# pwszValueName : LPCWSTR -> LPCWSTR
# pdwValue : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。