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

SLFireEvent

関数
指定アプリケーションに対するライセンスイベントを発生させる。
DLLSLC.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT SLFireEvent(
    void* hSLC,
    LPCWSTR pwszEventId,
    const GUID* pApplicationId
);

パラメーター

名前方向説明
hSLCvoid*inSLOpenで取得したSLCハンドル。
pwszEventIdLPCWSTRin発火させるイベントの識別子を指すUnicode文字列。
pApplicationIdGUID*in対象アプリケーションを識別するGUIDへのポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

SLFireEvent = ctypes.windll.slc.SLFireEvent
SLFireEvent.restype = ctypes.c_int
SLFireEvent.argtypes = [
    ctypes.POINTER(None),  # hSLC : void*
    wintypes.LPCWSTR,  # pwszEventId : LPCWSTR
    ctypes.c_void_p,  # pApplicationId : GUID*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	slc = windows.NewLazySystemDLL("SLC.dll")
	procSLFireEvent = slc.NewProc("SLFireEvent")
)

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

extern "slc" fn SLFireEvent(
    hSLC: ?*anyopaque, // void*
    pwszEventId: [*c]const u16, // LPCWSTR
    pApplicationId: [*c]GUID // GUID*
) callconv(std.os.windows.WINAPI) i32;
proc SLFireEvent(
    hSLC: pointer,  # void*
    pwszEventId: WideCString,  # LPCWSTR
    pApplicationId: ptr GUID  # GUID*
): int32 {.importc: "SLFireEvent", stdcall, dynlib: "SLC.dll".}
pragma(lib, "slc");
extern(Windows)
int SLFireEvent(
    void* hSLC,   // void*
    const(wchar)* pwszEventId,   // LPCWSTR
    GUID* pApplicationId   // GUID*
);
ccall((:SLFireEvent, "SLC.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cwstring, Ptr{GUID}),
      hSLC, pwszEventId, pApplicationId)
# hSLC : void* -> Ptr{Cvoid}
# pwszEventId : LPCWSTR -> Cwstring
# pApplicationId : GUID* -> Ptr{GUID}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SLFireEvent(
    void* hSLC,
    const uint16_t* pwszEventId,
    void* pApplicationId);
]]
local slc = ffi.load("slc")
-- slc.SLFireEvent(hSLC, pwszEventId, pApplicationId)
-- hSLC : void*
-- pwszEventId : LPCWSTR
-- pApplicationId : GUID*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SLC.dll');
const SLFireEvent = lib.func('__stdcall', 'SLFireEvent', 'int32_t', ['void *', 'str16', 'void *']);
// SLFireEvent(hSLC, pwszEventId, pApplicationId)
// hSLC : void* -> 'void *'
// pwszEventId : LPCWSTR -> 'str16'
// pApplicationId : GUID* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SLC.dll", {
  SLFireEvent: { parameters: ["pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.SLFireEvent(hSLC, pwszEventId, pApplicationId)
// hSLC : void* -> "pointer"
// pwszEventId : LPCWSTR -> "buffer"
// pApplicationId : GUID* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SLFireEvent(
    void* hSLC,
    const uint16_t* pwszEventId,
    void* pApplicationId);
C, "SLC.dll");
// $ffi->SLFireEvent(hSLC, pwszEventId, pApplicationId);
// hSLC : void*
// pwszEventId : LPCWSTR
// pApplicationId : GUID*
// 構造体/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 SLFireEvent(
        Pointer hSLC,   // void*
        WString pwszEventId,   // LPCWSTR
        Pointer pApplicationId   // GUID*
    );
}
@[Link("slc")]
lib LibSLC
  fun SLFireEvent = SLFireEvent(
    hSLC : Void*,   # void*
    pwszEventId : UInt16*,   # LPCWSTR
    pApplicationId : GUID*   # GUID*
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SLFireEventNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
typedef SLFireEventDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
final SLFireEvent = DynamicLibrary.open('SLC.dll')
    .lookupFunction<SLFireEventNative, SLFireEventDart>('SLFireEvent');
// hSLC : void* -> Pointer<Void>
// pwszEventId : LPCWSTR -> Pointer<Utf16>
// pApplicationId : GUID* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SLFireEvent(
  hSLC: Pointer;   // void*
  pwszEventId: PWideChar;   // LPCWSTR
  pApplicationId: PGUID   // GUID*
): Integer; stdcall;
  external 'SLC.dll' name 'SLFireEvent';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SLFireEvent"
  c_SLFireEvent :: Ptr () -> CWString -> Ptr () -> IO Int32
-- hSLC : void* -> Ptr ()
-- pwszEventId : LPCWSTR -> CWString
-- pApplicationId : GUID* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let slfireevent =
  foreign "SLFireEvent"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* hSLC : void* -> (ptr void) *)
(* pwszEventId : LPCWSTR -> (ptr uint16_t) *)
(* pApplicationId : GUID* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library slc (t "SLC.dll"))
(cffi:use-foreign-library slc)

(cffi:defcfun ("SLFireEvent" slfire-event :convention :stdcall) :int32
  (h-slc :pointer)   ; void*
  (pwsz-event-id (:string :encoding :utf-16le))   ; LPCWSTR
  (p-application-id :pointer))   ; GUID*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SLFireEvent = Win32::API::More->new('SLC',
    'int SLFireEvent(LPVOID hSLC, LPCWSTR pwszEventId, LPVOID pApplicationId)');
# my $ret = $SLFireEvent->Call($hSLC, $pwszEventId, $pApplicationId);
# hSLC : void* -> LPVOID
# pwszEventId : LPCWSTR -> LPCWSTR
# pApplicationId : GUID* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。