Win32 API 日本語リファレンス
ホームSystem.Performance › PdhConnectMachineA

PdhConnectMachineA

関数
リモートマシンへ接続する(ANSI版)。
DLLpdh.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// pdh.dll  (ANSI / -A)
#include <windows.h>

DWORD PdhConnectMachineA(
    LPCSTR szMachineName   // optional
);

パラメーター

名前方向
szMachineNameLPCSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

// pdh.dll  (ANSI / -A)
#include <windows.h>

DWORD PdhConnectMachineA(
    LPCSTR szMachineName   // optional
);
[DllImport("pdh.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint PdhConnectMachineA(
    [MarshalAs(UnmanagedType.LPStr)] string szMachineName   // LPCSTR optional
);
<DllImport("pdh.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function PdhConnectMachineA(
    <MarshalAs(UnmanagedType.LPStr)> szMachineName As String   ' LPCSTR optional
) As UInteger
End Function
' szMachineName : LPCSTR optional
Declare PtrSafe Function PdhConnectMachineA Lib "pdh" ( _
    ByVal szMachineName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PdhConnectMachineA = ctypes.windll.pdh.PdhConnectMachineA
PdhConnectMachineA.restype = wintypes.DWORD
PdhConnectMachineA.argtypes = [
    wintypes.LPCSTR,  # szMachineName : LPCSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('pdh.dll')
PdhConnectMachineA = Fiddle::Function.new(
  lib['PdhConnectMachineA'],
  [
    Fiddle::TYPE_VOIDP,  # szMachineName : LPCSTR optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "pdh")]
extern "system" {
    fn PdhConnectMachineA(
        szMachineName: *const u8  // LPCSTR optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("pdh.dll", CharSet = CharSet.Ansi)]
public static extern uint PdhConnectMachineA([MarshalAs(UnmanagedType.LPStr)] string szMachineName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhConnectMachineA' -Namespace Win32 -PassThru
# $api::PdhConnectMachineA(szMachineName)
#uselib "pdh.dll"
#func global PdhConnectMachineA "PdhConnectMachineA" sptr
; PdhConnectMachineA szMachineName   ; 戻り値は stat
; szMachineName : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "pdh.dll"
#cfunc global PdhConnectMachineA "PdhConnectMachineA" str
; res = PdhConnectMachineA(szMachineName)
; szMachineName : LPCSTR optional -> "str"
; DWORD PdhConnectMachineA(LPCSTR szMachineName)
#uselib "pdh.dll"
#cfunc global PdhConnectMachineA "PdhConnectMachineA" str
; res = PdhConnectMachineA(szMachineName)
; szMachineName : LPCSTR optional -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	pdh = windows.NewLazySystemDLL("pdh.dll")
	procPdhConnectMachineA = pdh.NewProc("PdhConnectMachineA")
)

// szMachineName (LPCSTR optional)
r1, _, err := procPdhConnectMachineA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szMachineName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PdhConnectMachineA(
  szMachineName: PAnsiChar   // LPCSTR optional
): DWORD; stdcall;
  external 'pdh.dll' name 'PdhConnectMachineA';
result := DllCall("pdh\PdhConnectMachineA"
    , "AStr", szMachineName   ; LPCSTR optional
    , "UInt")   ; return: DWORD
●PdhConnectMachineA(szMachineName) = DLL("pdh.dll", "dword PdhConnectMachineA(char*)")
# 呼び出し: PdhConnectMachineA(szMachineName)
# szMachineName : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。