Win32 API 日本語リファレンス
ホームNetworkManagement.WNet › NPOpenEnum

NPOpenEnum

関数
プロバイダーのネットワークリソース列挙を開始する。
DLLdavclnt.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// davclnt.dll
#include <windows.h>

DWORD NPOpenEnum(
    DWORD dwScope,
    DWORD dwType,
    DWORD dwUsage,
    NETRESOURCEW* lpNetResource,   // optional
    HANDLE* lphEnum
);

パラメーター

名前方向説明
dwScopeDWORDin列挙範囲(接続済み/グローバル等)を指定する値。
dwTypeDWORDin列挙対象のリソース種別を指定する値。
dwUsageDWORDin列挙対象の用途を絞るフラグ。
lpNetResourceNETRESOURCEW*inoptional列挙の起点となるNETRESOURCEW構造体。最上位ならNULL。
lphEnumHANDLE*out後続のNPEnumResourceで使う列挙ハンドルを受け取る出力先。

戻り値の型: DWORD

各言語での呼び出し定義

// davclnt.dll
#include <windows.h>

DWORD NPOpenEnum(
    DWORD dwScope,
    DWORD dwType,
    DWORD dwUsage,
    NETRESOURCEW* lpNetResource,   // optional
    HANDLE* lphEnum
);
[DllImport("davclnt.dll", ExactSpelling = true)]
static extern uint NPOpenEnum(
    uint dwScope,   // DWORD
    uint dwType,   // DWORD
    uint dwUsage,   // DWORD
    IntPtr lpNetResource,   // NETRESOURCEW* optional
    IntPtr lphEnum   // HANDLE* out
);
<DllImport("davclnt.dll", ExactSpelling:=True)>
Public Shared Function NPOpenEnum(
    dwScope As UInteger,   ' DWORD
    dwType As UInteger,   ' DWORD
    dwUsage As UInteger,   ' DWORD
    lpNetResource As IntPtr,   ' NETRESOURCEW* optional
    lphEnum As IntPtr   ' HANDLE* out
) As UInteger
End Function
' dwScope : DWORD
' dwType : DWORD
' dwUsage : DWORD
' lpNetResource : NETRESOURCEW* optional
' lphEnum : HANDLE* out
Declare PtrSafe Function NPOpenEnum Lib "davclnt" ( _
    ByVal dwScope As Long, _
    ByVal dwType As Long, _
    ByVal dwUsage As Long, _
    ByVal lpNetResource As LongPtr, _
    ByVal lphEnum As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NPOpenEnum = ctypes.windll.davclnt.NPOpenEnum
NPOpenEnum.restype = wintypes.DWORD
NPOpenEnum.argtypes = [
    wintypes.DWORD,  # dwScope : DWORD
    wintypes.DWORD,  # dwType : DWORD
    wintypes.DWORD,  # dwUsage : DWORD
    ctypes.c_void_p,  # lpNetResource : NETRESOURCEW* optional
    ctypes.c_void_p,  # lphEnum : HANDLE* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('davclnt.dll')
NPOpenEnum = Fiddle::Function.new(
  lib['NPOpenEnum'],
  [
    -Fiddle::TYPE_INT,  # dwScope : DWORD
    -Fiddle::TYPE_INT,  # dwType : DWORD
    -Fiddle::TYPE_INT,  # dwUsage : DWORD
    Fiddle::TYPE_VOIDP,  # lpNetResource : NETRESOURCEW* optional
    Fiddle::TYPE_VOIDP,  # lphEnum : HANDLE* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "davclnt")]
extern "system" {
    fn NPOpenEnum(
        dwScope: u32,  // DWORD
        dwType: u32,  // DWORD
        dwUsage: u32,  // DWORD
        lpNetResource: *mut NETRESOURCEW,  // NETRESOURCEW* optional
        lphEnum: *mut *mut core::ffi::c_void  // HANDLE* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("davclnt.dll")]
public static extern uint NPOpenEnum(uint dwScope, uint dwType, uint dwUsage, IntPtr lpNetResource, IntPtr lphEnum);
"@
$api = Add-Type -MemberDefinition $sig -Name 'davclnt_NPOpenEnum' -Namespace Win32 -PassThru
# $api::NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum)
#uselib "davclnt.dll"
#func global NPOpenEnum "NPOpenEnum" sptr, sptr, sptr, sptr, sptr
; NPOpenEnum dwScope, dwType, dwUsage, varptr(lpNetResource), lphEnum   ; 戻り値は stat
; dwScope : DWORD -> "sptr"
; dwType : DWORD -> "sptr"
; dwUsage : DWORD -> "sptr"
; lpNetResource : NETRESOURCEW* optional -> "sptr"
; lphEnum : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "davclnt.dll"
#cfunc global NPOpenEnum "NPOpenEnum" int, int, int, var, sptr
; res = NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum)
; dwScope : DWORD -> "int"
; dwType : DWORD -> "int"
; dwUsage : DWORD -> "int"
; lpNetResource : NETRESOURCEW* optional -> "var"
; lphEnum : HANDLE* out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD NPOpenEnum(DWORD dwScope, DWORD dwType, DWORD dwUsage, NETRESOURCEW* lpNetResource, HANDLE* lphEnum)
#uselib "davclnt.dll"
#cfunc global NPOpenEnum "NPOpenEnum" int, int, int, var, intptr
; res = NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum)
; dwScope : DWORD -> "int"
; dwType : DWORD -> "int"
; dwUsage : DWORD -> "int"
; lpNetResource : NETRESOURCEW* optional -> "var"
; lphEnum : HANDLE* out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	davclnt = windows.NewLazySystemDLL("davclnt.dll")
	procNPOpenEnum = davclnt.NewProc("NPOpenEnum")
)

// dwScope (DWORD), dwType (DWORD), dwUsage (DWORD), lpNetResource (NETRESOURCEW* optional), lphEnum (HANDLE* out)
r1, _, err := procNPOpenEnum.Call(
	uintptr(dwScope),
	uintptr(dwType),
	uintptr(dwUsage),
	uintptr(lpNetResource),
	uintptr(lphEnum),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function NPOpenEnum(
  dwScope: DWORD;   // DWORD
  dwType: DWORD;   // DWORD
  dwUsage: DWORD;   // DWORD
  lpNetResource: Pointer;   // NETRESOURCEW* optional
  lphEnum: Pointer   // HANDLE* out
): DWORD; stdcall;
  external 'davclnt.dll' name 'NPOpenEnum';
result := DllCall("davclnt\NPOpenEnum"
    , "UInt", dwScope   ; DWORD
    , "UInt", dwType   ; DWORD
    , "UInt", dwUsage   ; DWORD
    , "Ptr", lpNetResource   ; NETRESOURCEW* optional
    , "Ptr", lphEnum   ; HANDLE* out
    , "UInt")   ; return: DWORD
●NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum) = DLL("davclnt.dll", "dword NPOpenEnum(dword, dword, dword, void*, void*)")
# 呼び出し: NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum)
# dwScope : DWORD -> "dword"
# dwType : DWORD -> "dword"
# dwUsage : DWORD -> "dword"
# lpNetResource : NETRESOURCEW* optional -> "void*"
# lphEnum : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "davclnt" fn NPOpenEnum(
    dwScope: u32, // DWORD
    dwType: u32, // DWORD
    dwUsage: u32, // DWORD
    lpNetResource: [*c]NETRESOURCEW, // NETRESOURCEW* optional
    lphEnum: ?*anyopaque // HANDLE* out
) callconv(std.os.windows.WINAPI) u32;
proc NPOpenEnum(
    dwScope: uint32,  # DWORD
    dwType: uint32,  # DWORD
    dwUsage: uint32,  # DWORD
    lpNetResource: ptr NETRESOURCEW,  # NETRESOURCEW* optional
    lphEnum: pointer  # HANDLE* out
): uint32 {.importc: "NPOpenEnum", stdcall, dynlib: "davclnt.dll".}
pragma(lib, "davclnt");
extern(Windows)
uint NPOpenEnum(
    uint dwScope,   // DWORD
    uint dwType,   // DWORD
    uint dwUsage,   // DWORD
    NETRESOURCEW* lpNetResource,   // NETRESOURCEW* optional
    void* lphEnum   // HANDLE* out
);
ccall((:NPOpenEnum, "davclnt.dll"), stdcall, UInt32,
      (UInt32, UInt32, UInt32, Ptr{NETRESOURCEW}, Ptr{Cvoid}),
      dwScope, dwType, dwUsage, lpNetResource, lphEnum)
# dwScope : DWORD -> UInt32
# dwType : DWORD -> UInt32
# dwUsage : DWORD -> UInt32
# lpNetResource : NETRESOURCEW* optional -> Ptr{NETRESOURCEW}
# lphEnum : HANDLE* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t NPOpenEnum(
    uint32_t dwScope,
    uint32_t dwType,
    uint32_t dwUsage,
    void* lpNetResource,
    void* lphEnum);
]]
local davclnt = ffi.load("davclnt")
-- davclnt.NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum)
-- dwScope : DWORD
-- dwType : DWORD
-- dwUsage : DWORD
-- lpNetResource : NETRESOURCEW* optional
-- lphEnum : HANDLE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('davclnt.dll');
const NPOpenEnum = lib.func('__stdcall', 'NPOpenEnum', 'uint32_t', ['uint32_t', 'uint32_t', 'uint32_t', 'void *', 'void *']);
// NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum)
// dwScope : DWORD -> 'uint32_t'
// dwType : DWORD -> 'uint32_t'
// dwUsage : DWORD -> 'uint32_t'
// lpNetResource : NETRESOURCEW* optional -> 'void *'
// lphEnum : HANDLE* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("davclnt.dll", {
  NPOpenEnum: { parameters: ["u32", "u32", "u32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum)
// dwScope : DWORD -> "u32"
// dwType : DWORD -> "u32"
// dwUsage : DWORD -> "u32"
// lpNetResource : NETRESOURCEW* optional -> "pointer"
// lphEnum : HANDLE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t NPOpenEnum(
    uint32_t dwScope,
    uint32_t dwType,
    uint32_t dwUsage,
    void* lpNetResource,
    void* lphEnum);
C, "davclnt.dll");
// $ffi->NPOpenEnum(dwScope, dwType, dwUsage, lpNetResource, lphEnum);
// dwScope : DWORD
// dwType : DWORD
// dwUsage : DWORD
// lpNetResource : NETRESOURCEW* optional
// lphEnum : HANDLE* 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 Davclnt extends StdCallLibrary {
    Davclnt INSTANCE = Native.load("davclnt", Davclnt.class);
    int NPOpenEnum(
        int dwScope,   // DWORD
        int dwType,   // DWORD
        int dwUsage,   // DWORD
        Pointer lpNetResource,   // NETRESOURCEW* optional
        Pointer lphEnum   // HANDLE* out
    );
}
@[Link("davclnt")]
lib Libdavclnt
  fun NPOpenEnum = NPOpenEnum(
    dwScope : UInt32,   # DWORD
    dwType : UInt32,   # DWORD
    dwUsage : UInt32,   # DWORD
    lpNetResource : NETRESOURCEW*,   # NETRESOURCEW* optional
    lphEnum : Void*   # HANDLE* out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef NPOpenEnumNative = Uint32 Function(Uint32, Uint32, Uint32, Pointer<Void>, Pointer<Void>);
typedef NPOpenEnumDart = int Function(int, int, int, Pointer<Void>, Pointer<Void>);
final NPOpenEnum = DynamicLibrary.open('davclnt.dll')
    .lookupFunction<NPOpenEnumNative, NPOpenEnumDart>('NPOpenEnum');
// dwScope : DWORD -> Uint32
// dwType : DWORD -> Uint32
// dwUsage : DWORD -> Uint32
// lpNetResource : NETRESOURCEW* optional -> Pointer<Void>
// lphEnum : HANDLE* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function NPOpenEnum(
  dwScope: DWORD;   // DWORD
  dwType: DWORD;   // DWORD
  dwUsage: DWORD;   // DWORD
  lpNetResource: Pointer;   // NETRESOURCEW* optional
  lphEnum: Pointer   // HANDLE* out
): DWORD; stdcall;
  external 'davclnt.dll' name 'NPOpenEnum';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "NPOpenEnum"
  c_NPOpenEnum :: Word32 -> Word32 -> Word32 -> Ptr () -> Ptr () -> IO Word32
-- dwScope : DWORD -> Word32
-- dwType : DWORD -> Word32
-- dwUsage : DWORD -> Word32
-- lpNetResource : NETRESOURCEW* optional -> Ptr ()
-- lphEnum : HANDLE* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let npopenenum =
  foreign "NPOpenEnum"
    (uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* dwScope : DWORD -> uint32_t *)
(* dwType : DWORD -> uint32_t *)
(* dwUsage : DWORD -> uint32_t *)
(* lpNetResource : NETRESOURCEW* optional -> (ptr void) *)
(* lphEnum : HANDLE* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library davclnt (t "davclnt.dll"))
(cffi:use-foreign-library davclnt)

(cffi:defcfun ("NPOpenEnum" npopen-enum :convention :stdcall) :uint32
  (dw-scope :uint32)   ; DWORD
  (dw-type :uint32)   ; DWORD
  (dw-usage :uint32)   ; DWORD
  (lp-net-resource :pointer)   ; NETRESOURCEW* optional
  (lph-enum :pointer))   ; HANDLE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $NPOpenEnum = Win32::API::More->new('davclnt',
    'DWORD NPOpenEnum(DWORD dwScope, DWORD dwType, DWORD dwUsage, LPVOID lpNetResource, HANDLE lphEnum)');
# my $ret = $NPOpenEnum->Call($dwScope, $dwType, $dwUsage, $lpNetResource, $lphEnum);
# dwScope : DWORD -> DWORD
# dwType : DWORD -> DWORD
# dwUsage : DWORD -> DWORD
# lpNetResource : NETRESOURCEW* optional -> LPVOID
# lphEnum : HANDLE* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型