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

SLActivateProduct

関数
製品SKUをライセンスサーバー経由でアクティブ化する。
DLLslcext.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT SLActivateProduct(
    void* hSLC,
    const GUID* pProductSkuId,
    DWORD cbAppSpecificData,   // optional
    const void* pvAppSpecificData,   // optional
    const SL_ACTIVATION_INFO_HEADER* pActivationInfo,   // optional
    LPCWSTR pwszProxyServer,   // optional
    WORD wProxyPort   // optional
);

パラメーター

名前方向
hSLCvoid*in
pProductSkuIdGUID*in
cbAppSpecificDataDWORDinoptional
pvAppSpecificDatavoid*inoptional
pActivationInfoSL_ACTIVATION_INFO_HEADER*inoptional
pwszProxyServerLPCWSTRinoptional
wProxyPortWORDinoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SLActivateProduct(
    void* hSLC,
    const GUID* pProductSkuId,
    DWORD cbAppSpecificData,   // optional
    const void* pvAppSpecificData,   // optional
    const SL_ACTIVATION_INFO_HEADER* pActivationInfo,   // optional
    LPCWSTR pwszProxyServer,   // optional
    WORD wProxyPort   // optional
);
[DllImport("slcext.dll", ExactSpelling = true)]
static extern int SLActivateProduct(
    IntPtr hSLC,   // void*
    ref Guid pProductSkuId,   // GUID*
    uint cbAppSpecificData,   // DWORD optional
    IntPtr pvAppSpecificData,   // void* optional
    IntPtr pActivationInfo,   // SL_ACTIVATION_INFO_HEADER* optional
    [MarshalAs(UnmanagedType.LPWStr)] string pwszProxyServer,   // LPCWSTR optional
    ushort wProxyPort   // WORD optional
);
<DllImport("slcext.dll", ExactSpelling:=True)>
Public Shared Function SLActivateProduct(
    hSLC As IntPtr,   ' void*
    ByRef pProductSkuId As Guid,   ' GUID*
    cbAppSpecificData As UInteger,   ' DWORD optional
    pvAppSpecificData As IntPtr,   ' void* optional
    pActivationInfo As IntPtr,   ' SL_ACTIVATION_INFO_HEADER* optional
    <MarshalAs(UnmanagedType.LPWStr)> pwszProxyServer As String,   ' LPCWSTR optional
    wProxyPort As UShort   ' WORD optional
) As Integer
End Function
' hSLC : void*
' pProductSkuId : GUID*
' cbAppSpecificData : DWORD optional
' pvAppSpecificData : void* optional
' pActivationInfo : SL_ACTIVATION_INFO_HEADER* optional
' pwszProxyServer : LPCWSTR optional
' wProxyPort : WORD optional
Declare PtrSafe Function SLActivateProduct Lib "slcext" ( _
    ByVal hSLC As LongPtr, _
    ByVal pProductSkuId As LongPtr, _
    ByVal cbAppSpecificData As Long, _
    ByVal pvAppSpecificData As LongPtr, _
    ByVal pActivationInfo As LongPtr, _
    ByVal pwszProxyServer As LongPtr, _
    ByVal wProxyPort As Integer) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SLActivateProduct = ctypes.windll.slcext.SLActivateProduct
SLActivateProduct.restype = ctypes.c_int
SLActivateProduct.argtypes = [
    ctypes.POINTER(None),  # hSLC : void*
    ctypes.c_void_p,  # pProductSkuId : GUID*
    wintypes.DWORD,  # cbAppSpecificData : DWORD optional
    ctypes.POINTER(None),  # pvAppSpecificData : void* optional
    ctypes.c_void_p,  # pActivationInfo : SL_ACTIVATION_INFO_HEADER* optional
    wintypes.LPCWSTR,  # pwszProxyServer : LPCWSTR optional
    ctypes.c_ushort,  # wProxyPort : WORD optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	slcext = windows.NewLazySystemDLL("slcext.dll")
	procSLActivateProduct = slcext.NewProc("SLActivateProduct")
)

// hSLC (void*), pProductSkuId (GUID*), cbAppSpecificData (DWORD optional), pvAppSpecificData (void* optional), pActivationInfo (SL_ACTIVATION_INFO_HEADER* optional), pwszProxyServer (LPCWSTR optional), wProxyPort (WORD optional)
r1, _, err := procSLActivateProduct.Call(
	uintptr(hSLC),
	uintptr(pProductSkuId),
	uintptr(cbAppSpecificData),
	uintptr(pvAppSpecificData),
	uintptr(pActivationInfo),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszProxyServer))),
	uintptr(wProxyPort),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SLActivateProduct(
  hSLC: Pointer;   // void*
  pProductSkuId: PGUID;   // GUID*
  cbAppSpecificData: DWORD;   // DWORD optional
  pvAppSpecificData: Pointer;   // void* optional
  pActivationInfo: Pointer;   // SL_ACTIVATION_INFO_HEADER* optional
  pwszProxyServer: PWideChar;   // LPCWSTR optional
  wProxyPort: Word   // WORD optional
): Integer; stdcall;
  external 'slcext.dll' name 'SLActivateProduct';
result := DllCall("slcext\SLActivateProduct"
    , "Ptr", hSLC   ; void*
    , "Ptr", pProductSkuId   ; GUID*
    , "UInt", cbAppSpecificData   ; DWORD optional
    , "Ptr", pvAppSpecificData   ; void* optional
    , "Ptr", pActivationInfo   ; SL_ACTIVATION_INFO_HEADER* optional
    , "WStr", pwszProxyServer   ; LPCWSTR optional
    , "UShort", wProxyPort   ; WORD optional
    , "Int")   ; return: HRESULT
●SLActivateProduct(hSLC, pProductSkuId, cbAppSpecificData, pvAppSpecificData, pActivationInfo, pwszProxyServer, wProxyPort) = DLL("slcext.dll", "int SLActivateProduct(void*, void*, dword, void*, void*, char*, int)")
# 呼び出し: SLActivateProduct(hSLC, pProductSkuId, cbAppSpecificData, pvAppSpecificData, pActivationInfo, pwszProxyServer, wProxyPort)
# hSLC : void* -> "void*"
# pProductSkuId : GUID* -> "void*"
# cbAppSpecificData : DWORD optional -> "dword"
# pvAppSpecificData : void* optional -> "void*"
# pActivationInfo : SL_ACTIVATION_INFO_HEADER* optional -> "void*"
# pwszProxyServer : LPCWSTR optional -> "char*"
# wProxyPort : WORD optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。