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