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

SLOpen

関数
ソフトウェアライセンスクライアントへのハンドルを開く。
DLLSLC.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT SLOpen(
    void** phSLC
);

パラメーター

名前方向説明
phSLCvoid**outソフトウェアライセンスクライアント(SLC)のハンドルを受け取るポインタ。SLCloseで閉じる。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

SLOpen = ctypes.windll.slc.SLOpen
SLOpen.restype = ctypes.c_int
SLOpen.argtypes = [
    ctypes.c_void_p,  # phSLC : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SLC.dll')
SLOpen = Fiddle::Function.new(
  lib['SLOpen'],
  [
    Fiddle::TYPE_VOIDP,  # phSLC : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "slc")]
extern "system" {
    fn SLOpen(
        phSLC: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SLC.dll")]
public static extern int SLOpen(IntPtr phSLC);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SLC_SLOpen' -Namespace Win32 -PassThru
# $api::SLOpen(phSLC)
#uselib "SLC.dll"
#func global SLOpen "SLOpen" sptr
; SLOpen phSLC   ; 戻り値は stat
; phSLC : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SLC.dll"
#cfunc global SLOpen "SLOpen" sptr
; res = SLOpen(phSLC)
; phSLC : void** out -> "sptr"
; HRESULT SLOpen(void** phSLC)
#uselib "SLC.dll"
#cfunc global SLOpen "SLOpen" intptr
; res = SLOpen(phSLC)
; phSLC : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	slc = windows.NewLazySystemDLL("SLC.dll")
	procSLOpen = slc.NewProc("SLOpen")
)

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

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

typedef SLOpenNative = Int32 Function(Pointer<Void>);
typedef SLOpenDart = int Function(Pointer<Void>);
final SLOpen = DynamicLibrary.open('SLC.dll')
    .lookupFunction<SLOpenNative, SLOpenDart>('SLOpen');
// phSLC : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SLOpen(
  phSLC: Pointer   // void** out
): Integer; stdcall;
  external 'SLC.dll' name 'SLOpen';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SLOpen"
  c_SLOpen :: Ptr () -> IO Int32
-- phSLC : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let slopen =
  foreign "SLOpen"
    ((ptr void) @-> returning int32_t)
(* phSLC : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library slc (t "SLC.dll"))
(cffi:use-foreign-library slc)

(cffi:defcfun ("SLOpen" slopen :convention :stdcall) :int32
  (ph-slc :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SLOpen = Win32::API::More->new('SLC',
    'int SLOpen(LPVOID phSLC)');
# my $ret = $SLOpen->Call($phSLC);
# phSLC : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。