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

SLSetCurrentProductKey

関数
製品SKUに対する現在のプロダクトキーを設定する。
DLLSLC.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT SLSetCurrentProductKey(
    void* hSLC,
    const GUID* pProductSkuId,
    const GUID* pProductKeyId
);

パラメーター

名前方向
hSLCvoid*in
pProductSkuIdGUID*in
pProductKeyIdGUID*in

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

SLSetCurrentProductKey = ctypes.windll.slc.SLSetCurrentProductKey
SLSetCurrentProductKey.restype = ctypes.c_int
SLSetCurrentProductKey.argtypes = [
    ctypes.POINTER(None),  # hSLC : void*
    ctypes.c_void_p,  # pProductSkuId : GUID*
    ctypes.c_void_p,  # pProductKeyId : GUID*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	slc = windows.NewLazySystemDLL("SLC.dll")
	procSLSetCurrentProductKey = slc.NewProc("SLSetCurrentProductKey")
)

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