ホーム › System.UserAccessLogging › UalRegisterProduct
UalRegisterProduct
関数UALに製品名やロール名などの製品情報を登録する。
シグネチャ
// ualapi.dll
#include <windows.h>
HRESULT UalRegisterProduct(
LPCWSTR wszProductName,
LPCWSTR wszRoleName,
LPCWSTR wszGuid
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| wszProductName | LPCWSTR | in | 登録する製品名(Unicode)。 |
| wszRoleName | LPCWSTR | in | 製品が担うロール名(Unicode)。 |
| wszGuid | LPCWSTR | in | 製品を一意に識別するGUID文字列(Unicode)。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// ualapi.dll
#include <windows.h>
HRESULT UalRegisterProduct(
LPCWSTR wszProductName,
LPCWSTR wszRoleName,
LPCWSTR wszGuid
);[DllImport("ualapi.dll", ExactSpelling = true)]
static extern int UalRegisterProduct(
[MarshalAs(UnmanagedType.LPWStr)] string wszProductName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string wszRoleName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string wszGuid // LPCWSTR
);<DllImport("ualapi.dll", ExactSpelling:=True)>
Public Shared Function UalRegisterProduct(
<MarshalAs(UnmanagedType.LPWStr)> wszProductName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> wszRoleName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> wszGuid As String ' LPCWSTR
) As Integer
End Function' wszProductName : LPCWSTR
' wszRoleName : LPCWSTR
' wszGuid : LPCWSTR
Declare PtrSafe Function UalRegisterProduct Lib "ualapi" ( _
ByVal wszProductName As LongPtr, _
ByVal wszRoleName As LongPtr, _
ByVal wszGuid As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UalRegisterProduct = ctypes.windll.ualapi.UalRegisterProduct
UalRegisterProduct.restype = ctypes.c_int
UalRegisterProduct.argtypes = [
wintypes.LPCWSTR, # wszProductName : LPCWSTR
wintypes.LPCWSTR, # wszRoleName : LPCWSTR
wintypes.LPCWSTR, # wszGuid : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ualapi.dll')
UalRegisterProduct = Fiddle::Function.new(
lib['UalRegisterProduct'],
[
Fiddle::TYPE_VOIDP, # wszProductName : LPCWSTR
Fiddle::TYPE_VOIDP, # wszRoleName : LPCWSTR
Fiddle::TYPE_VOIDP, # wszGuid : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "ualapi")]
extern "system" {
fn UalRegisterProduct(
wszProductName: *const u16, // LPCWSTR
wszRoleName: *const u16, // LPCWSTR
wszGuid: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ualapi.dll")]
public static extern int UalRegisterProduct([MarshalAs(UnmanagedType.LPWStr)] string wszProductName, [MarshalAs(UnmanagedType.LPWStr)] string wszRoleName, [MarshalAs(UnmanagedType.LPWStr)] string wszGuid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ualapi_UalRegisterProduct' -Namespace Win32 -PassThru
# $api::UalRegisterProduct(wszProductName, wszRoleName, wszGuid)#uselib "ualapi.dll"
#func global UalRegisterProduct "UalRegisterProduct" sptr, sptr, sptr
; UalRegisterProduct wszProductName, wszRoleName, wszGuid ; 戻り値は stat
; wszProductName : LPCWSTR -> "sptr"
; wszRoleName : LPCWSTR -> "sptr"
; wszGuid : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ualapi.dll"
#cfunc global UalRegisterProduct "UalRegisterProduct" wstr, wstr, wstr
; res = UalRegisterProduct(wszProductName, wszRoleName, wszGuid)
; wszProductName : LPCWSTR -> "wstr"
; wszRoleName : LPCWSTR -> "wstr"
; wszGuid : LPCWSTR -> "wstr"; HRESULT UalRegisterProduct(LPCWSTR wszProductName, LPCWSTR wszRoleName, LPCWSTR wszGuid)
#uselib "ualapi.dll"
#cfunc global UalRegisterProduct "UalRegisterProduct" wstr, wstr, wstr
; res = UalRegisterProduct(wszProductName, wszRoleName, wszGuid)
; wszProductName : LPCWSTR -> "wstr"
; wszRoleName : LPCWSTR -> "wstr"
; wszGuid : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ualapi = windows.NewLazySystemDLL("ualapi.dll")
procUalRegisterProduct = ualapi.NewProc("UalRegisterProduct")
)
// wszProductName (LPCWSTR), wszRoleName (LPCWSTR), wszGuid (LPCWSTR)
r1, _, err := procUalRegisterProduct.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszProductName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszRoleName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszGuid))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction UalRegisterProduct(
wszProductName: PWideChar; // LPCWSTR
wszRoleName: PWideChar; // LPCWSTR
wszGuid: PWideChar // LPCWSTR
): Integer; stdcall;
external 'ualapi.dll' name 'UalRegisterProduct';result := DllCall("ualapi\UalRegisterProduct"
, "WStr", wszProductName ; LPCWSTR
, "WStr", wszRoleName ; LPCWSTR
, "WStr", wszGuid ; LPCWSTR
, "Int") ; return: HRESULT●UalRegisterProduct(wszProductName, wszRoleName, wszGuid) = DLL("ualapi.dll", "int UalRegisterProduct(char*, char*, char*)")
# 呼び出し: UalRegisterProduct(wszProductName, wszRoleName, wszGuid)
# wszProductName : LPCWSTR -> "char*"
# wszRoleName : LPCWSTR -> "char*"
# wszGuid : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ualapi" fn UalRegisterProduct(
wszProductName: [*c]const u16, // LPCWSTR
wszRoleName: [*c]const u16, // LPCWSTR
wszGuid: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc UalRegisterProduct(
wszProductName: WideCString, # LPCWSTR
wszRoleName: WideCString, # LPCWSTR
wszGuid: WideCString # LPCWSTR
): int32 {.importc: "UalRegisterProduct", stdcall, dynlib: "ualapi.dll".}pragma(lib, "ualapi");
extern(Windows)
int UalRegisterProduct(
const(wchar)* wszProductName, // LPCWSTR
const(wchar)* wszRoleName, // LPCWSTR
const(wchar)* wszGuid // LPCWSTR
);ccall((:UalRegisterProduct, "ualapi.dll"), stdcall, Int32,
(Cwstring, Cwstring, Cwstring),
wszProductName, wszRoleName, wszGuid)
# wszProductName : LPCWSTR -> Cwstring
# wszRoleName : LPCWSTR -> Cwstring
# wszGuid : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t UalRegisterProduct(
const uint16_t* wszProductName,
const uint16_t* wszRoleName,
const uint16_t* wszGuid);
]]
local ualapi = ffi.load("ualapi")
-- ualapi.UalRegisterProduct(wszProductName, wszRoleName, wszGuid)
-- wszProductName : LPCWSTR
-- wszRoleName : LPCWSTR
-- wszGuid : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ualapi.dll');
const UalRegisterProduct = lib.func('__stdcall', 'UalRegisterProduct', 'int32_t', ['str16', 'str16', 'str16']);
// UalRegisterProduct(wszProductName, wszRoleName, wszGuid)
// wszProductName : LPCWSTR -> 'str16'
// wszRoleName : LPCWSTR -> 'str16'
// wszGuid : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ualapi.dll", {
UalRegisterProduct: { parameters: ["buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.UalRegisterProduct(wszProductName, wszRoleName, wszGuid)
// wszProductName : LPCWSTR -> "buffer"
// wszRoleName : LPCWSTR -> "buffer"
// wszGuid : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t UalRegisterProduct(
const uint16_t* wszProductName,
const uint16_t* wszRoleName,
const uint16_t* wszGuid);
C, "ualapi.dll");
// $ffi->UalRegisterProduct(wszProductName, wszRoleName, wszGuid);
// wszProductName : LPCWSTR
// wszRoleName : LPCWSTR
// wszGuid : LPCWSTR
// 構造体/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 Ualapi extends StdCallLibrary {
Ualapi INSTANCE = Native.load("ualapi", Ualapi.class);
int UalRegisterProduct(
WString wszProductName, // LPCWSTR
WString wszRoleName, // LPCWSTR
WString wszGuid // LPCWSTR
);
}@[Link("ualapi")]
lib Libualapi
fun UalRegisterProduct = UalRegisterProduct(
wszProductName : UInt16*, # LPCWSTR
wszRoleName : UInt16*, # LPCWSTR
wszGuid : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UalRegisterProductNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef UalRegisterProductDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final UalRegisterProduct = DynamicLibrary.open('ualapi.dll')
.lookupFunction<UalRegisterProductNative, UalRegisterProductDart>('UalRegisterProduct');
// wszProductName : LPCWSTR -> Pointer<Utf16>
// wszRoleName : LPCWSTR -> Pointer<Utf16>
// wszGuid : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UalRegisterProduct(
wszProductName: PWideChar; // LPCWSTR
wszRoleName: PWideChar; // LPCWSTR
wszGuid: PWideChar // LPCWSTR
): Integer; stdcall;
external 'ualapi.dll' name 'UalRegisterProduct';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UalRegisterProduct"
c_UalRegisterProduct :: CWString -> CWString -> CWString -> IO Int32
-- wszProductName : LPCWSTR -> CWString
-- wszRoleName : LPCWSTR -> CWString
-- wszGuid : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ualregisterproduct =
foreign "UalRegisterProduct"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* wszProductName : LPCWSTR -> (ptr uint16_t) *)
(* wszRoleName : LPCWSTR -> (ptr uint16_t) *)
(* wszGuid : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ualapi (t "ualapi.dll"))
(cffi:use-foreign-library ualapi)
(cffi:defcfun ("UalRegisterProduct" ual-register-product :convention :stdcall) :int32
(wsz-product-name (:string :encoding :utf-16le)) ; LPCWSTR
(wsz-role-name (:string :encoding :utf-16le)) ; LPCWSTR
(wsz-guid (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UalRegisterProduct = Win32::API::More->new('ualapi',
'int UalRegisterProduct(LPCWSTR wszProductName, LPCWSTR wszRoleName, LPCWSTR wszGuid)');
# my $ret = $UalRegisterProduct->Call($wszProductName, $wszRoleName, $wszGuid);
# wszProductName : LPCWSTR -> LPCWSTR
# wszRoleName : LPCWSTR -> LPCWSTR
# wszGuid : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。