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

SLGetPolicyInformationDWORD

関数
ライセンスポリシーの指定値をDWORD型で取得する。
DLLSLC.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT SLGetPolicyInformationDWORD(
    void* hSLC,
    LPCWSTR pwszValueName,
    DWORD* pdwValue
);

パラメーター

名前方向
hSLCvoid*in
pwszValueNameLPCWSTRin
pdwValueDWORD*out

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // HRESULT
function 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)。