ホーム › System.EventLog › RegisterEventSourceA
RegisterEventSourceA
関数イベントソースを登録しハンドルを取得する(ANSI版)。
シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
HANDLE RegisterEventSourceA(
LPCSTR lpUNCServerName, // optional
LPCSTR lpSourceName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpUNCServerName | LPCSTR | inoptional |
| lpSourceName | LPCSTR | in |
戻り値の型: HANDLE
各言語での呼び出し定義
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
HANDLE RegisterEventSourceA(
LPCSTR lpUNCServerName, // optional
LPCSTR lpSourceName
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr RegisterEventSourceA(
[MarshalAs(UnmanagedType.LPStr)] string lpUNCServerName, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string lpSourceName // LPCSTR
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function RegisterEventSourceA(
<MarshalAs(UnmanagedType.LPStr)> lpUNCServerName As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> lpSourceName As String ' LPCSTR
) As IntPtr
End Function' lpUNCServerName : LPCSTR optional
' lpSourceName : LPCSTR
Declare PtrSafe Function RegisterEventSourceA Lib "advapi32" ( _
ByVal lpUNCServerName As String, _
ByVal lpSourceName As String) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegisterEventSourceA = ctypes.windll.advapi32.RegisterEventSourceA
RegisterEventSourceA.restype = ctypes.c_void_p
RegisterEventSourceA.argtypes = [
wintypes.LPCSTR, # lpUNCServerName : LPCSTR optional
wintypes.LPCSTR, # lpSourceName : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
RegisterEventSourceA = Fiddle::Function.new(
lib['RegisterEventSourceA'],
[
Fiddle::TYPE_VOIDP, # lpUNCServerName : LPCSTR optional
Fiddle::TYPE_VOIDP, # lpSourceName : LPCSTR
],
Fiddle::TYPE_VOIDP)#[link(name = "advapi32")]
extern "system" {
fn RegisterEventSourceA(
lpUNCServerName: *const u8, // LPCSTR optional
lpSourceName: *const u8 // LPCSTR
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr RegisterEventSourceA([MarshalAs(UnmanagedType.LPStr)] string lpUNCServerName, [MarshalAs(UnmanagedType.LPStr)] string lpSourceName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegisterEventSourceA' -Namespace Win32 -PassThru
# $api::RegisterEventSourceA(lpUNCServerName, lpSourceName)#uselib "ADVAPI32.dll"
#func global RegisterEventSourceA "RegisterEventSourceA" sptr, sptr
; RegisterEventSourceA lpUNCServerName, lpSourceName ; 戻り値は stat
; lpUNCServerName : LPCSTR optional -> "sptr"
; lpSourceName : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global RegisterEventSourceA "RegisterEventSourceA" str, str
; res = RegisterEventSourceA(lpUNCServerName, lpSourceName)
; lpUNCServerName : LPCSTR optional -> "str"
; lpSourceName : LPCSTR -> "str"; HANDLE RegisterEventSourceA(LPCSTR lpUNCServerName, LPCSTR lpSourceName)
#uselib "ADVAPI32.dll"
#cfunc global RegisterEventSourceA "RegisterEventSourceA" str, str
; res = RegisterEventSourceA(lpUNCServerName, lpSourceName)
; lpUNCServerName : LPCSTR optional -> "str"
; lpSourceName : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procRegisterEventSourceA = advapi32.NewProc("RegisterEventSourceA")
)
// lpUNCServerName (LPCSTR optional), lpSourceName (LPCSTR)
r1, _, err := procRegisterEventSourceA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpUNCServerName))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpSourceName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HANDLEfunction RegisterEventSourceA(
lpUNCServerName: PAnsiChar; // LPCSTR optional
lpSourceName: PAnsiChar // LPCSTR
): THandle; stdcall;
external 'ADVAPI32.dll' name 'RegisterEventSourceA';result := DllCall("ADVAPI32\RegisterEventSourceA"
, "AStr", lpUNCServerName ; LPCSTR optional
, "AStr", lpSourceName ; LPCSTR
, "Ptr") ; return: HANDLE●RegisterEventSourceA(lpUNCServerName, lpSourceName) = DLL("ADVAPI32.dll", "void* RegisterEventSourceA(char*, char*)")
# 呼び出し: RegisterEventSourceA(lpUNCServerName, lpSourceName)
# lpUNCServerName : LPCSTR optional -> "char*"
# lpSourceName : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。