ホーム › NetworkManagement.WNet › NPGetConnectionPerformance
NPGetConnectionPerformance
関数リモート接続の性能情報をプロバイダーから取得する。
シグネチャ
// NTLANMAN.dll
#include <windows.h>
DWORD NPGetConnectionPerformance(
LPCWSTR lpRemoteName,
NETCONNECTINFOSTRUCT* lpNetConnectInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpRemoteName | LPCWSTR | in | 性能情報を取得する対象のリモートリソース名のワイド文字列。 |
| lpNetConnectInfo | NETCONNECTINFOSTRUCT* | out | 接続性能情報を受け取るNETCONNECTINFOSTRUCT構造体へのポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// NTLANMAN.dll
#include <windows.h>
DWORD NPGetConnectionPerformance(
LPCWSTR lpRemoteName,
NETCONNECTINFOSTRUCT* lpNetConnectInfo
);[DllImport("NTLANMAN.dll", ExactSpelling = true)]
static extern uint NPGetConnectionPerformance(
[MarshalAs(UnmanagedType.LPWStr)] string lpRemoteName, // LPCWSTR
IntPtr lpNetConnectInfo // NETCONNECTINFOSTRUCT* out
);<DllImport("NTLANMAN.dll", ExactSpelling:=True)>
Public Shared Function NPGetConnectionPerformance(
<MarshalAs(UnmanagedType.LPWStr)> lpRemoteName As String, ' LPCWSTR
lpNetConnectInfo As IntPtr ' NETCONNECTINFOSTRUCT* out
) As UInteger
End Function' lpRemoteName : LPCWSTR
' lpNetConnectInfo : NETCONNECTINFOSTRUCT* out
Declare PtrSafe Function NPGetConnectionPerformance Lib "ntlanman" ( _
ByVal lpRemoteName As LongPtr, _
ByVal lpNetConnectInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NPGetConnectionPerformance = ctypes.windll.ntlanman.NPGetConnectionPerformance
NPGetConnectionPerformance.restype = wintypes.DWORD
NPGetConnectionPerformance.argtypes = [
wintypes.LPCWSTR, # lpRemoteName : LPCWSTR
ctypes.c_void_p, # lpNetConnectInfo : NETCONNECTINFOSTRUCT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NTLANMAN.dll')
NPGetConnectionPerformance = Fiddle::Function.new(
lib['NPGetConnectionPerformance'],
[
Fiddle::TYPE_VOIDP, # lpRemoteName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpNetConnectInfo : NETCONNECTINFOSTRUCT* out
],
-Fiddle::TYPE_INT)#[link(name = "ntlanman")]
extern "system" {
fn NPGetConnectionPerformance(
lpRemoteName: *const u16, // LPCWSTR
lpNetConnectInfo: *mut NETCONNECTINFOSTRUCT // NETCONNECTINFOSTRUCT* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NTLANMAN.dll")]
public static extern uint NPGetConnectionPerformance([MarshalAs(UnmanagedType.LPWStr)] string lpRemoteName, IntPtr lpNetConnectInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTLANMAN_NPGetConnectionPerformance' -Namespace Win32 -PassThru
# $api::NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo)#uselib "NTLANMAN.dll"
#func global NPGetConnectionPerformance "NPGetConnectionPerformance" sptr, sptr
; NPGetConnectionPerformance lpRemoteName, varptr(lpNetConnectInfo) ; 戻り値は stat
; lpRemoteName : LPCWSTR -> "sptr"
; lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "NTLANMAN.dll" #cfunc global NPGetConnectionPerformance "NPGetConnectionPerformance" wstr, var ; res = NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo) ; lpRemoteName : LPCWSTR -> "wstr" ; lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "NTLANMAN.dll" #cfunc global NPGetConnectionPerformance "NPGetConnectionPerformance" wstr, sptr ; res = NPGetConnectionPerformance(lpRemoteName, varptr(lpNetConnectInfo)) ; lpRemoteName : LPCWSTR -> "wstr" ; lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD NPGetConnectionPerformance(LPCWSTR lpRemoteName, NETCONNECTINFOSTRUCT* lpNetConnectInfo) #uselib "NTLANMAN.dll" #cfunc global NPGetConnectionPerformance "NPGetConnectionPerformance" wstr, var ; res = NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo) ; lpRemoteName : LPCWSTR -> "wstr" ; lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD NPGetConnectionPerformance(LPCWSTR lpRemoteName, NETCONNECTINFOSTRUCT* lpNetConnectInfo) #uselib "NTLANMAN.dll" #cfunc global NPGetConnectionPerformance "NPGetConnectionPerformance" wstr, intptr ; res = NPGetConnectionPerformance(lpRemoteName, varptr(lpNetConnectInfo)) ; lpRemoteName : LPCWSTR -> "wstr" ; lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ntlanman = windows.NewLazySystemDLL("NTLANMAN.dll")
procNPGetConnectionPerformance = ntlanman.NewProc("NPGetConnectionPerformance")
)
// lpRemoteName (LPCWSTR), lpNetConnectInfo (NETCONNECTINFOSTRUCT* out)
r1, _, err := procNPGetConnectionPerformance.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpRemoteName))),
uintptr(lpNetConnectInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction NPGetConnectionPerformance(
lpRemoteName: PWideChar; // LPCWSTR
lpNetConnectInfo: Pointer // NETCONNECTINFOSTRUCT* out
): DWORD; stdcall;
external 'NTLANMAN.dll' name 'NPGetConnectionPerformance';result := DllCall("NTLANMAN\NPGetConnectionPerformance"
, "WStr", lpRemoteName ; LPCWSTR
, "Ptr", lpNetConnectInfo ; NETCONNECTINFOSTRUCT* out
, "UInt") ; return: DWORD●NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo) = DLL("NTLANMAN.dll", "dword NPGetConnectionPerformance(char*, void*)")
# 呼び出し: NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo)
# lpRemoteName : LPCWSTR -> "char*"
# lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ntlanman" fn NPGetConnectionPerformance(
lpRemoteName: [*c]const u16, // LPCWSTR
lpNetConnectInfo: [*c]NETCONNECTINFOSTRUCT // NETCONNECTINFOSTRUCT* out
) callconv(std.os.windows.WINAPI) u32;proc NPGetConnectionPerformance(
lpRemoteName: WideCString, # LPCWSTR
lpNetConnectInfo: ptr NETCONNECTINFOSTRUCT # NETCONNECTINFOSTRUCT* out
): uint32 {.importc: "NPGetConnectionPerformance", stdcall, dynlib: "NTLANMAN.dll".}pragma(lib, "ntlanman");
extern(Windows)
uint NPGetConnectionPerformance(
const(wchar)* lpRemoteName, // LPCWSTR
NETCONNECTINFOSTRUCT* lpNetConnectInfo // NETCONNECTINFOSTRUCT* out
);ccall((:NPGetConnectionPerformance, "NTLANMAN.dll"), stdcall, UInt32,
(Cwstring, Ptr{NETCONNECTINFOSTRUCT}),
lpRemoteName, lpNetConnectInfo)
# lpRemoteName : LPCWSTR -> Cwstring
# lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> Ptr{NETCONNECTINFOSTRUCT}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t NPGetConnectionPerformance(
const uint16_t* lpRemoteName,
void* lpNetConnectInfo);
]]
local ntlanman = ffi.load("ntlanman")
-- ntlanman.NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo)
-- lpRemoteName : LPCWSTR
-- lpNetConnectInfo : NETCONNECTINFOSTRUCT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NTLANMAN.dll');
const NPGetConnectionPerformance = lib.func('__stdcall', 'NPGetConnectionPerformance', 'uint32_t', ['str16', 'void *']);
// NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo)
// lpRemoteName : LPCWSTR -> 'str16'
// lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NTLANMAN.dll", {
NPGetConnectionPerformance: { parameters: ["buffer", "pointer"], result: "u32" },
});
// lib.symbols.NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo)
// lpRemoteName : LPCWSTR -> "buffer"
// lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t NPGetConnectionPerformance(
const uint16_t* lpRemoteName,
void* lpNetConnectInfo);
C, "NTLANMAN.dll");
// $ffi->NPGetConnectionPerformance(lpRemoteName, lpNetConnectInfo);
// lpRemoteName : LPCWSTR
// lpNetConnectInfo : NETCONNECTINFOSTRUCT* out
// 構造体/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 Ntlanman extends StdCallLibrary {
Ntlanman INSTANCE = Native.load("ntlanman", Ntlanman.class);
int NPGetConnectionPerformance(
WString lpRemoteName, // LPCWSTR
Pointer lpNetConnectInfo // NETCONNECTINFOSTRUCT* out
);
}@[Link("ntlanman")]
lib LibNTLANMAN
fun NPGetConnectionPerformance = NPGetConnectionPerformance(
lpRemoteName : UInt16*, # LPCWSTR
lpNetConnectInfo : NETCONNECTINFOSTRUCT* # NETCONNECTINFOSTRUCT* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NPGetConnectionPerformanceNative = Uint32 Function(Pointer<Utf16>, Pointer<Void>);
typedef NPGetConnectionPerformanceDart = int Function(Pointer<Utf16>, Pointer<Void>);
final NPGetConnectionPerformance = DynamicLibrary.open('NTLANMAN.dll')
.lookupFunction<NPGetConnectionPerformanceNative, NPGetConnectionPerformanceDart>('NPGetConnectionPerformance');
// lpRemoteName : LPCWSTR -> Pointer<Utf16>
// lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NPGetConnectionPerformance(
lpRemoteName: PWideChar; // LPCWSTR
lpNetConnectInfo: Pointer // NETCONNECTINFOSTRUCT* out
): DWORD; stdcall;
external 'NTLANMAN.dll' name 'NPGetConnectionPerformance';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NPGetConnectionPerformance"
c_NPGetConnectionPerformance :: CWString -> Ptr () -> IO Word32
-- lpRemoteName : LPCWSTR -> CWString
-- lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let npgetconnectionperformance =
foreign "NPGetConnectionPerformance"
((ptr uint16_t) @-> (ptr void) @-> returning uint32_t)
(* lpRemoteName : LPCWSTR -> (ptr uint16_t) *)
(* lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ntlanman (t "NTLANMAN.dll"))
(cffi:use-foreign-library ntlanman)
(cffi:defcfun ("NPGetConnectionPerformance" npget-connection-performance :convention :stdcall) :uint32
(lp-remote-name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-net-connect-info :pointer)) ; NETCONNECTINFOSTRUCT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NPGetConnectionPerformance = Win32::API::More->new('NTLANMAN',
'DWORD NPGetConnectionPerformance(LPCWSTR lpRemoteName, LPVOID lpNetConnectInfo)');
# my $ret = $NPGetConnectionPerformance->Call($lpRemoteName, $lpNetConnectInfo);
# lpRemoteName : LPCWSTR -> LPCWSTR
# lpNetConnectInfo : NETCONNECTINFOSTRUCT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。