ホーム › System.UserAccessLogging › UalRegisterProduct
UalRegisterProduct
関数UALに製品名やロール名などの製品情報を登録する。
シグネチャ
// ualapi.dll
#include <windows.h>
HRESULT UalRegisterProduct(
LPCWSTR wszProductName,
LPCWSTR wszRoleName,
LPCWSTR wszGuid
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| wszProductName | LPCWSTR | in |
| wszRoleName | LPCWSTR | in |
| wszGuid | LPCWSTR | in |
戻り値の型: 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)。