ホーム › Security.Authentication.Identity › SLGetLicense
SLGetLicense
関数指定ライセンスファイルIDのライセンスデータを取得する。
シグネチャ
// SLC.dll
#include <windows.h>
HRESULT SLGetLicense(
void* hSLC,
const GUID* pLicenseFileId,
DWORD* pcbLicenseFile,
BYTE** ppbLicenseFile
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hSLC | void* | in | SLOpenで取得したSLCハンドル。 |
| pLicenseFileId | GUID* | in | 取得対象のライセンスファイルを識別するGUIDへのポインタ。 |
| pcbLicenseFile | DWORD* | out | ppbLicenseFileに格納されたデータのバイト長を受け取るDWORDへのポインタ。 |
| ppbLicenseFile | BYTE** | 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 方式にも切替可。#uselib "SLC.dll" #cfunc global SLGetLicense "SLGetLicense" sptr, sptr, sptr, sptr ; res = SLGetLicense(hSLC, varptr(pLicenseFileId), varptr(pcbLicenseFile), varptr(ppbLicenseFile)) ; hSLC : void* -> "sptr" ; pLicenseFileId : GUID* -> "sptr" ; pcbLicenseFile : DWORD* out -> "sptr" ; ppbLicenseFile : BYTE** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; HRESULT SLGetLicense(void* hSLC, GUID* pLicenseFileId, DWORD* pcbLicenseFile, BYTE** ppbLicenseFile) #uselib "SLC.dll" #cfunc global SLGetLicense "SLGetLicense" intptr, intptr, intptr, intptr ; res = SLGetLicense(hSLC, varptr(pLicenseFileId), varptr(pcbLicenseFile), varptr(ppbLicenseFile)) ; hSLC : void* -> "intptr" ; pLicenseFileId : GUID* -> "intptr" ; pcbLicenseFile : DWORD* out -> "intptr" ; ppbLicenseFile : BYTE** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。const std = @import("std");
extern "slc" fn SLGetLicense(
hSLC: ?*anyopaque, // void*
pLicenseFileId: [*c]GUID, // GUID*
pcbLicenseFile: [*c]u32, // DWORD* out
ppbLicenseFile: [*c][*c]u8 // BYTE** out
) callconv(std.os.windows.WINAPI) i32;proc SLGetLicense(
hSLC: pointer, # void*
pLicenseFileId: ptr GUID, # GUID*
pcbLicenseFile: ptr uint32, # DWORD* out
ppbLicenseFile: ptr uint8 # BYTE** out
): int32 {.importc: "SLGetLicense", stdcall, dynlib: "SLC.dll".}pragma(lib, "slc");
extern(Windows)
int SLGetLicense(
void* hSLC, // void*
GUID* pLicenseFileId, // GUID*
uint* pcbLicenseFile, // DWORD* out
ubyte** ppbLicenseFile // BYTE** out
);ccall((:SLGetLicense, "SLC.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{GUID}, Ptr{UInt32}, Ptr{UInt8}),
hSLC, pLicenseFileId, pcbLicenseFile, ppbLicenseFile)
# hSLC : void* -> Ptr{Cvoid}
# pLicenseFileId : GUID* -> Ptr{GUID}
# pcbLicenseFile : DWORD* out -> Ptr{UInt32}
# ppbLicenseFile : BYTE** out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SLGetLicense(
void* hSLC,
void* pLicenseFileId,
uint32_t* pcbLicenseFile,
uint8_t** ppbLicenseFile);
]]
local slc = ffi.load("slc")
-- slc.SLGetLicense(hSLC, pLicenseFileId, pcbLicenseFile, ppbLicenseFile)
-- hSLC : void*
-- pLicenseFileId : GUID*
-- pcbLicenseFile : DWORD* out
-- ppbLicenseFile : BYTE** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SLC.dll');
const SLGetLicense = lib.func('__stdcall', 'SLGetLicense', 'int32_t', ['void *', 'void *', 'uint32_t *', 'uint8_t *']);
// SLGetLicense(hSLC, pLicenseFileId, pcbLicenseFile, ppbLicenseFile)
// hSLC : void* -> 'void *'
// pLicenseFileId : GUID* -> 'void *'
// pcbLicenseFile : DWORD* out -> 'uint32_t *'
// ppbLicenseFile : BYTE** out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SLC.dll", {
SLGetLicense: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SLGetLicense(hSLC, pLicenseFileId, pcbLicenseFile, ppbLicenseFile)
// hSLC : void* -> "pointer"
// pLicenseFileId : GUID* -> "pointer"
// pcbLicenseFile : DWORD* out -> "pointer"
// ppbLicenseFile : BYTE** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SLGetLicense(
void* hSLC,
void* pLicenseFileId,
uint32_t* pcbLicenseFile,
uint8_t** ppbLicenseFile);
C, "SLC.dll");
// $ffi->SLGetLicense(hSLC, pLicenseFileId, pcbLicenseFile, ppbLicenseFile);
// hSLC : void*
// pLicenseFileId : GUID*
// pcbLicenseFile : DWORD* out
// ppbLicenseFile : 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 SLGetLicense(
Pointer hSLC, // void*
Pointer pLicenseFileId, // GUID*
IntByReference pcbLicenseFile, // DWORD* out
Pointer ppbLicenseFile // BYTE** out
);
}@[Link("slc")]
lib LibSLC
fun SLGetLicense = SLGetLicense(
hSLC : Void*, # void*
pLicenseFileId : GUID*, # GUID*
pcbLicenseFile : UInt32*, # DWORD* out
ppbLicenseFile : 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 SLGetLicenseNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Uint8>);
typedef SLGetLicenseDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Uint8>);
final SLGetLicense = DynamicLibrary.open('SLC.dll')
.lookupFunction<SLGetLicenseNative, SLGetLicenseDart>('SLGetLicense');
// hSLC : void* -> Pointer<Void>
// pLicenseFileId : GUID* -> Pointer<Void>
// pcbLicenseFile : DWORD* out -> Pointer<Uint32>
// ppbLicenseFile : BYTE** out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SLGetLicense(
hSLC: Pointer; // void*
pLicenseFileId: PGUID; // GUID*
pcbLicenseFile: Pointer; // DWORD* out
ppbLicenseFile: Pointer // BYTE** out
): Integer; stdcall;
external 'SLC.dll' name 'SLGetLicense';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SLGetLicense"
c_SLGetLicense :: Ptr () -> Ptr () -> Ptr Word32 -> Ptr Word8 -> IO Int32
-- hSLC : void* -> Ptr ()
-- pLicenseFileId : GUID* -> Ptr ()
-- pcbLicenseFile : DWORD* out -> Ptr Word32
-- ppbLicenseFile : BYTE** out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let slgetlicense =
foreign "SLGetLicense"
((ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> (ptr uint8_t) @-> returning int32_t)
(* hSLC : void* -> (ptr void) *)
(* pLicenseFileId : GUID* -> (ptr void) *)
(* pcbLicenseFile : DWORD* out -> (ptr uint32_t) *)
(* ppbLicenseFile : 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 ("SLGetLicense" slget-license :convention :stdcall) :int32
(h-slc :pointer) ; void*
(p-license-file-id :pointer) ; GUID*
(pcb-license-file :pointer) ; DWORD* out
(ppb-license-file :pointer)) ; BYTE** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SLGetLicense = Win32::API::More->new('SLC',
'int SLGetLicense(LPVOID hSLC, LPVOID pLicenseFileId, LPVOID pcbLicenseFile, LPVOID ppbLicenseFile)');
# my $ret = $SLGetLicense->Call($hSLC, $pLicenseFileId, $pcbLicenseFile, $ppbLicenseFile);
# hSLC : void* -> LPVOID
# pLicenseFileId : GUID* -> LPVOID
# pcbLicenseFile : DWORD* out -> LPVOID
# ppbLicenseFile : BYTE** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。