ホーム › System.Performance › SetServiceAsTrustedW
SetServiceAsTrustedW
関数パフォーマンス収集で信頼済みとなるようサービスを設定する。
シグネチャ
// loadperf.dll (Unicode / -W)
#include <windows.h>
DWORD SetServiceAsTrustedW(
LPCWSTR szReserved, // optional
LPCWSTR szServiceName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szReserved | LPCWSTR | inoptional |
| szServiceName | LPCWSTR | in |
戻り値の型: DWORD
各言語での呼び出し定義
// loadperf.dll (Unicode / -W)
#include <windows.h>
DWORD SetServiceAsTrustedW(
LPCWSTR szReserved, // optional
LPCWSTR szServiceName
);[DllImport("loadperf.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint SetServiceAsTrustedW(
[MarshalAs(UnmanagedType.LPWStr)] string szReserved, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string szServiceName // LPCWSTR
);<DllImport("loadperf.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SetServiceAsTrustedW(
<MarshalAs(UnmanagedType.LPWStr)> szReserved As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> szServiceName As String ' LPCWSTR
) As UInteger
End Function' szReserved : LPCWSTR optional
' szServiceName : LPCWSTR
Declare PtrSafe Function SetServiceAsTrustedW Lib "loadperf" ( _
ByVal szReserved As LongPtr, _
ByVal szServiceName As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetServiceAsTrustedW = ctypes.windll.loadperf.SetServiceAsTrustedW
SetServiceAsTrustedW.restype = wintypes.DWORD
SetServiceAsTrustedW.argtypes = [
wintypes.LPCWSTR, # szReserved : LPCWSTR optional
wintypes.LPCWSTR, # szServiceName : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('loadperf.dll')
SetServiceAsTrustedW = Fiddle::Function.new(
lib['SetServiceAsTrustedW'],
[
Fiddle::TYPE_VOIDP, # szReserved : LPCWSTR optional
Fiddle::TYPE_VOIDP, # szServiceName : LPCWSTR
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "loadperf")]
extern "system" {
fn SetServiceAsTrustedW(
szReserved: *const u16, // LPCWSTR optional
szServiceName: *const u16 // LPCWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("loadperf.dll", CharSet = CharSet.Unicode)]
public static extern uint SetServiceAsTrustedW([MarshalAs(UnmanagedType.LPWStr)] string szReserved, [MarshalAs(UnmanagedType.LPWStr)] string szServiceName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'loadperf_SetServiceAsTrustedW' -Namespace Win32 -PassThru
# $api::SetServiceAsTrustedW(szReserved, szServiceName)#uselib "loadperf.dll"
#func global SetServiceAsTrustedW "SetServiceAsTrustedW" wptr, wptr
; SetServiceAsTrustedW szReserved, szServiceName ; 戻り値は stat
; szReserved : LPCWSTR optional -> "wptr"
; szServiceName : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "loadperf.dll"
#cfunc global SetServiceAsTrustedW "SetServiceAsTrustedW" wstr, wstr
; res = SetServiceAsTrustedW(szReserved, szServiceName)
; szReserved : LPCWSTR optional -> "wstr"
; szServiceName : LPCWSTR -> "wstr"; DWORD SetServiceAsTrustedW(LPCWSTR szReserved, LPCWSTR szServiceName)
#uselib "loadperf.dll"
#cfunc global SetServiceAsTrustedW "SetServiceAsTrustedW" wstr, wstr
; res = SetServiceAsTrustedW(szReserved, szServiceName)
; szReserved : LPCWSTR optional -> "wstr"
; szServiceName : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
loadperf = windows.NewLazySystemDLL("loadperf.dll")
procSetServiceAsTrustedW = loadperf.NewProc("SetServiceAsTrustedW")
)
// szReserved (LPCWSTR optional), szServiceName (LPCWSTR)
r1, _, err := procSetServiceAsTrustedW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szReserved))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szServiceName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetServiceAsTrustedW(
szReserved: PWideChar; // LPCWSTR optional
szServiceName: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'loadperf.dll' name 'SetServiceAsTrustedW';result := DllCall("loadperf\SetServiceAsTrustedW"
, "WStr", szReserved ; LPCWSTR optional
, "WStr", szServiceName ; LPCWSTR
, "UInt") ; return: DWORD●SetServiceAsTrustedW(szReserved, szServiceName) = DLL("loadperf.dll", "dword SetServiceAsTrustedW(char*, char*)")
# 呼び出し: SetServiceAsTrustedW(szReserved, szServiceName)
# szReserved : LPCWSTR optional -> "char*"
# szServiceName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。