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

SLGetLicense

関数
指定ライセンスファイルIDのライセンスデータを取得する。
DLLSLC.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT SLGetLicense(
    void* hSLC,
    const GUID* pLicenseFileId,
    DWORD* pcbLicenseFile,
    BYTE** ppbLicenseFile
);

パラメーター

名前方向
hSLCvoid*in
pLicenseFileIdGUID*in
pcbLicenseFileDWORD*out
ppbLicenseFileBYTE**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SLGetLicense(
    void* hSLC,
    const GUID* pLicenseFileId,
    DWORD* pcbLicenseFile,
    BYTE** ppbLicenseFile
);
[DllImport("SLC.dll", ExactSpelling = true)]
static extern int SLGetLicense(
    IntPtr hSLC,   // void*
    ref Guid pLicenseFileId,   // GUID*
    out uint pcbLicenseFile,   // DWORD* out
    IntPtr ppbLicenseFile   // BYTE** out
);
<DllImport("SLC.dll", ExactSpelling:=True)>
Public Shared Function SLGetLicense(
    hSLC As IntPtr,   ' void*
    ByRef pLicenseFileId As Guid,   ' GUID*
    <Out> ByRef pcbLicenseFile As UInteger,   ' DWORD* out
    ppbLicenseFile As IntPtr   ' BYTE** out
) As Integer
End Function
' hSLC : void*
' pLicenseFileId : GUID*
' pcbLicenseFile : DWORD* out
' ppbLicenseFile : BYTE** out
Declare PtrSafe Function SLGetLicense Lib "slc" ( _
    ByVal hSLC As LongPtr, _
    ByVal pLicenseFileId As LongPtr, _
    ByRef pcbLicenseFile As Long, _
    ByVal ppbLicenseFile As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SLGetLicense = ctypes.windll.slc.SLGetLicense
SLGetLicense.restype = ctypes.c_int
SLGetLicense.argtypes = [
    ctypes.POINTER(None),  # hSLC : void*
    ctypes.c_void_p,  # pLicenseFileId : GUID*
    ctypes.POINTER(wintypes.DWORD),  # pcbLicenseFile : DWORD* out
    ctypes.c_void_p,  # ppbLicenseFile : BYTE** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	slc = windows.NewLazySystemDLL("SLC.dll")
	procSLGetLicense = slc.NewProc("SLGetLicense")
)

// hSLC (void*), pLicenseFileId (GUID*), pcbLicenseFile (DWORD* out), ppbLicenseFile (BYTE** out)
r1, _, err := procSLGetLicense.Call(
	uintptr(hSLC),
	uintptr(pLicenseFileId),
	uintptr(pcbLicenseFile),
	uintptr(ppbLicenseFile),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SLGetLicense(
  hSLC: Pointer;   // void*
  pLicenseFileId: PGUID;   // GUID*
  pcbLicenseFile: Pointer;   // DWORD* out
  ppbLicenseFile: Pointer   // BYTE** out
): Integer; stdcall;
  external 'SLC.dll' name 'SLGetLicense';
result := DllCall("SLC\SLGetLicense"
    , "Ptr", hSLC   ; void*
    , "Ptr", pLicenseFileId   ; GUID*
    , "Ptr", pcbLicenseFile   ; DWORD* out
    , "Ptr", ppbLicenseFile   ; BYTE** out
    , "Int")   ; return: HRESULT
●SLGetLicense(hSLC, pLicenseFileId, pcbLicenseFile, ppbLicenseFile) = DLL("SLC.dll", "int SLGetLicense(void*, void*, void*, void*)")
# 呼び出し: SLGetLicense(hSLC, pLicenseFileId, pcbLicenseFile, ppbLicenseFile)
# hSLC : void* -> "void*"
# pLicenseFileId : GUID* -> "void*"
# pcbLicenseFile : DWORD* out -> "void*"
# ppbLicenseFile : BYTE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。