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

WNetAddConnection4W

関数
認証バッファを用いてネットワークリソースに接続する(Unicode版)。
DLLMPR.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// MPR.dll  (Unicode / -W)
#include <windows.h>

WIN32_ERROR WNetAddConnection4W(
    HWND hwndOwner,   // optional
    NETRESOURCEW* lpNetResource,
    void* pAuthBuffer,
    DWORD cbAuthBuffer,
    NET_CONNECT_FLAGS dwFlags,
    BYTE* lpUseOptions,
    DWORD cbUseOptions
);

パラメーター

名前方向説明
hwndOwnerHWNDinoptional資格情報入力ダイアログの親ウィンドウハンドル。不要ならNULL可。
lpNetResourceNETRESOURCEW*in接続先や種別を記述したNETRESOURCEW構造体へのポインタ。
pAuthBuffervoid*in認証情報を格納したバッファへのポインタ。NULL可。
cbAuthBufferDWORDinpAuthBufferのバイト数。
dwFlagsNET_CONNECT_FLAGSin接続動作を制御するNET_CONNECT_FLAGSフラグ。
lpUseOptionsBYTE*in拡張接続オプションを格納したバッファ(NETRESOURCE_USE_OPTIONS)へのポインタ。
cbUseOptionsDWORDinlpUseOptionsのバイト数。

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

// MPR.dll  (Unicode / -W)
#include <windows.h>

WIN32_ERROR WNetAddConnection4W(
    HWND hwndOwner,   // optional
    NETRESOURCEW* lpNetResource,
    void* pAuthBuffer,
    DWORD cbAuthBuffer,
    NET_CONNECT_FLAGS dwFlags,
    BYTE* lpUseOptions,
    DWORD cbUseOptions
);
[DllImport("MPR.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint WNetAddConnection4W(
    IntPtr hwndOwner,   // HWND optional
    IntPtr lpNetResource,   // NETRESOURCEW*
    IntPtr pAuthBuffer,   // void*
    uint cbAuthBuffer,   // DWORD
    uint dwFlags,   // NET_CONNECT_FLAGS
    IntPtr lpUseOptions,   // BYTE*
    uint cbUseOptions   // DWORD
);
<DllImport("MPR.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function WNetAddConnection4W(
    hwndOwner As IntPtr,   ' HWND optional
    lpNetResource As IntPtr,   ' NETRESOURCEW*
    pAuthBuffer As IntPtr,   ' void*
    cbAuthBuffer As UInteger,   ' DWORD
    dwFlags As UInteger,   ' NET_CONNECT_FLAGS
    lpUseOptions As IntPtr,   ' BYTE*
    cbUseOptions As UInteger   ' DWORD
) As UInteger
End Function
' hwndOwner : HWND optional
' lpNetResource : NETRESOURCEW*
' pAuthBuffer : void*
' cbAuthBuffer : DWORD
' dwFlags : NET_CONNECT_FLAGS
' lpUseOptions : BYTE*
' cbUseOptions : DWORD
Declare PtrSafe Function WNetAddConnection4W Lib "mpr" ( _
    ByVal hwndOwner As LongPtr, _
    ByVal lpNetResource As LongPtr, _
    ByVal pAuthBuffer As LongPtr, _
    ByVal cbAuthBuffer As Long, _
    ByVal dwFlags As Long, _
    ByVal lpUseOptions As LongPtr, _
    ByVal cbUseOptions As Long) 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

WNetAddConnection4W = ctypes.windll.mpr.WNetAddConnection4W
WNetAddConnection4W.restype = wintypes.DWORD
WNetAddConnection4W.argtypes = [
    wintypes.HANDLE,  # hwndOwner : HWND optional
    ctypes.c_void_p,  # lpNetResource : NETRESOURCEW*
    ctypes.POINTER(None),  # pAuthBuffer : void*
    wintypes.DWORD,  # cbAuthBuffer : DWORD
    wintypes.DWORD,  # dwFlags : NET_CONNECT_FLAGS
    ctypes.POINTER(ctypes.c_ubyte),  # lpUseOptions : BYTE*
    wintypes.DWORD,  # cbUseOptions : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MPR.dll')
WNetAddConnection4W = Fiddle::Function.new(
  lib['WNetAddConnection4W'],
  [
    Fiddle::TYPE_VOIDP,  # hwndOwner : HWND optional
    Fiddle::TYPE_VOIDP,  # lpNetResource : NETRESOURCEW*
    Fiddle::TYPE_VOIDP,  # pAuthBuffer : void*
    -Fiddle::TYPE_INT,  # cbAuthBuffer : DWORD
    -Fiddle::TYPE_INT,  # dwFlags : NET_CONNECT_FLAGS
    Fiddle::TYPE_VOIDP,  # lpUseOptions : BYTE*
    -Fiddle::TYPE_INT,  # cbUseOptions : DWORD
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "mpr")]
extern "system" {
    fn WNetAddConnection4W(
        hwndOwner: *mut core::ffi::c_void,  // HWND optional
        lpNetResource: *mut NETRESOURCEW,  // NETRESOURCEW*
        pAuthBuffer: *mut (),  // void*
        cbAuthBuffer: u32,  // DWORD
        dwFlags: u32,  // NET_CONNECT_FLAGS
        lpUseOptions: *mut u8,  // BYTE*
        cbUseOptions: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MPR.dll", CharSet = CharSet.Unicode)]
public static extern uint WNetAddConnection4W(IntPtr hwndOwner, IntPtr lpNetResource, IntPtr pAuthBuffer, uint cbAuthBuffer, uint dwFlags, IntPtr lpUseOptions, uint cbUseOptions);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MPR_WNetAddConnection4W' -Namespace Win32 -PassThru
# $api::WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions)
#uselib "MPR.dll"
#func global WNetAddConnection4W "WNetAddConnection4W" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; WNetAddConnection4W hwndOwner, varptr(lpNetResource), pAuthBuffer, cbAuthBuffer, dwFlags, varptr(lpUseOptions), cbUseOptions   ; 戻り値は stat
; hwndOwner : HWND optional -> "wptr"
; lpNetResource : NETRESOURCEW* -> "wptr"
; pAuthBuffer : void* -> "wptr"
; cbAuthBuffer : DWORD -> "wptr"
; dwFlags : NET_CONNECT_FLAGS -> "wptr"
; lpUseOptions : BYTE* -> "wptr"
; cbUseOptions : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MPR.dll"
#cfunc global WNetAddConnection4W "WNetAddConnection4W" sptr, var, sptr, int, int, var, int
; res = WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions)
; hwndOwner : HWND optional -> "sptr"
; lpNetResource : NETRESOURCEW* -> "var"
; pAuthBuffer : void* -> "sptr"
; cbAuthBuffer : DWORD -> "int"
; dwFlags : NET_CONNECT_FLAGS -> "int"
; lpUseOptions : BYTE* -> "var"
; cbUseOptions : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR WNetAddConnection4W(HWND hwndOwner, NETRESOURCEW* lpNetResource, void* pAuthBuffer, DWORD cbAuthBuffer, NET_CONNECT_FLAGS dwFlags, BYTE* lpUseOptions, DWORD cbUseOptions)
#uselib "MPR.dll"
#cfunc global WNetAddConnection4W "WNetAddConnection4W" intptr, var, intptr, int, int, var, int
; res = WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions)
; hwndOwner : HWND optional -> "intptr"
; lpNetResource : NETRESOURCEW* -> "var"
; pAuthBuffer : void* -> "intptr"
; cbAuthBuffer : DWORD -> "int"
; dwFlags : NET_CONNECT_FLAGS -> "int"
; lpUseOptions : BYTE* -> "var"
; cbUseOptions : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mpr = windows.NewLazySystemDLL("MPR.dll")
	procWNetAddConnection4W = mpr.NewProc("WNetAddConnection4W")
)

// hwndOwner (HWND optional), lpNetResource (NETRESOURCEW*), pAuthBuffer (void*), cbAuthBuffer (DWORD), dwFlags (NET_CONNECT_FLAGS), lpUseOptions (BYTE*), cbUseOptions (DWORD)
r1, _, err := procWNetAddConnection4W.Call(
	uintptr(hwndOwner),
	uintptr(lpNetResource),
	uintptr(pAuthBuffer),
	uintptr(cbAuthBuffer),
	uintptr(dwFlags),
	uintptr(lpUseOptions),
	uintptr(cbUseOptions),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function WNetAddConnection4W(
  hwndOwner: THandle;   // HWND optional
  lpNetResource: Pointer;   // NETRESOURCEW*
  pAuthBuffer: Pointer;   // void*
  cbAuthBuffer: DWORD;   // DWORD
  dwFlags: DWORD;   // NET_CONNECT_FLAGS
  lpUseOptions: Pointer;   // BYTE*
  cbUseOptions: DWORD   // DWORD
): DWORD; stdcall;
  external 'MPR.dll' name 'WNetAddConnection4W';
result := DllCall("MPR\WNetAddConnection4W"
    , "Ptr", hwndOwner   ; HWND optional
    , "Ptr", lpNetResource   ; NETRESOURCEW*
    , "Ptr", pAuthBuffer   ; void*
    , "UInt", cbAuthBuffer   ; DWORD
    , "UInt", dwFlags   ; NET_CONNECT_FLAGS
    , "Ptr", lpUseOptions   ; BYTE*
    , "UInt", cbUseOptions   ; DWORD
    , "UInt")   ; return: WIN32_ERROR
●WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions) = DLL("MPR.dll", "dword WNetAddConnection4W(void*, void*, void*, dword, dword, void*, dword)")
# 呼び出し: WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions)
# hwndOwner : HWND optional -> "void*"
# lpNetResource : NETRESOURCEW* -> "void*"
# pAuthBuffer : void* -> "void*"
# cbAuthBuffer : DWORD -> "dword"
# dwFlags : NET_CONNECT_FLAGS -> "dword"
# lpUseOptions : BYTE* -> "void*"
# cbUseOptions : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "mpr" fn WNetAddConnection4W(
    hwndOwner: ?*anyopaque, // HWND optional
    lpNetResource: [*c]NETRESOURCEW, // NETRESOURCEW*
    pAuthBuffer: ?*anyopaque, // void*
    cbAuthBuffer: u32, // DWORD
    dwFlags: u32, // NET_CONNECT_FLAGS
    lpUseOptions: [*c]u8, // BYTE*
    cbUseOptions: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc WNetAddConnection4W(
    hwndOwner: pointer,  # HWND optional
    lpNetResource: ptr NETRESOURCEW,  # NETRESOURCEW*
    pAuthBuffer: pointer,  # void*
    cbAuthBuffer: uint32,  # DWORD
    dwFlags: uint32,  # NET_CONNECT_FLAGS
    lpUseOptions: ptr uint8,  # BYTE*
    cbUseOptions: uint32  # DWORD
): uint32 {.importc: "WNetAddConnection4W", stdcall, dynlib: "MPR.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "mpr");
extern(Windows)
uint WNetAddConnection4W(
    void* hwndOwner,   // HWND optional
    NETRESOURCEW* lpNetResource,   // NETRESOURCEW*
    void* pAuthBuffer,   // void*
    uint cbAuthBuffer,   // DWORD
    uint dwFlags,   // NET_CONNECT_FLAGS
    ubyte* lpUseOptions,   // BYTE*
    uint cbUseOptions   // DWORD
);
ccall((:WNetAddConnection4W, "MPR.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Ptr{NETRESOURCEW}, Ptr{Cvoid}, UInt32, UInt32, Ptr{UInt8}, UInt32),
      hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions)
# hwndOwner : HWND optional -> Ptr{Cvoid}
# lpNetResource : NETRESOURCEW* -> Ptr{NETRESOURCEW}
# pAuthBuffer : void* -> Ptr{Cvoid}
# cbAuthBuffer : DWORD -> UInt32
# dwFlags : NET_CONNECT_FLAGS -> UInt32
# lpUseOptions : BYTE* -> Ptr{UInt8}
# cbUseOptions : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t WNetAddConnection4W(
    void* hwndOwner,
    void* lpNetResource,
    void* pAuthBuffer,
    uint32_t cbAuthBuffer,
    uint32_t dwFlags,
    uint8_t* lpUseOptions,
    uint32_t cbUseOptions);
]]
local mpr = ffi.load("mpr")
-- mpr.WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions)
-- hwndOwner : HWND optional
-- lpNetResource : NETRESOURCEW*
-- pAuthBuffer : void*
-- cbAuthBuffer : DWORD
-- dwFlags : NET_CONNECT_FLAGS
-- lpUseOptions : BYTE*
-- cbUseOptions : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('MPR.dll');
const WNetAddConnection4W = lib.func('__stdcall', 'WNetAddConnection4W', 'uint32_t', ['void *', 'void *', 'void *', 'uint32_t', 'uint32_t', 'uint8_t *', 'uint32_t']);
// WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions)
// hwndOwner : HWND optional -> 'void *'
// lpNetResource : NETRESOURCEW* -> 'void *'
// pAuthBuffer : void* -> 'void *'
// cbAuthBuffer : DWORD -> 'uint32_t'
// dwFlags : NET_CONNECT_FLAGS -> 'uint32_t'
// lpUseOptions : BYTE* -> 'uint8_t *'
// cbUseOptions : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MPR.dll", {
  WNetAddConnection4W: { parameters: ["pointer", "pointer", "pointer", "u32", "u32", "pointer", "u32"], result: "u32" },
});
// lib.symbols.WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions)
// hwndOwner : HWND optional -> "pointer"
// lpNetResource : NETRESOURCEW* -> "pointer"
// pAuthBuffer : void* -> "pointer"
// cbAuthBuffer : DWORD -> "u32"
// dwFlags : NET_CONNECT_FLAGS -> "u32"
// lpUseOptions : BYTE* -> "pointer"
// cbUseOptions : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t WNetAddConnection4W(
    void* hwndOwner,
    void* lpNetResource,
    void* pAuthBuffer,
    uint32_t cbAuthBuffer,
    uint32_t dwFlags,
    uint8_t* lpUseOptions,
    uint32_t cbUseOptions);
C, "MPR.dll");
// $ffi->WNetAddConnection4W(hwndOwner, lpNetResource, pAuthBuffer, cbAuthBuffer, dwFlags, lpUseOptions, cbUseOptions);
// hwndOwner : HWND optional
// lpNetResource : NETRESOURCEW*
// pAuthBuffer : void*
// cbAuthBuffer : DWORD
// dwFlags : NET_CONNECT_FLAGS
// lpUseOptions : BYTE*
// cbUseOptions : DWORD
// 構造体/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 Mpr extends StdCallLibrary {
    Mpr INSTANCE = Native.load("mpr", Mpr.class, W32APIOptions.UNICODE_OPTIONS);
    int WNetAddConnection4W(
        Pointer hwndOwner,   // HWND optional
        Pointer lpNetResource,   // NETRESOURCEW*
        Pointer pAuthBuffer,   // void*
        int cbAuthBuffer,   // DWORD
        int dwFlags,   // NET_CONNECT_FLAGS
        byte[] lpUseOptions,   // BYTE*
        int cbUseOptions   // DWORD
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("mpr")]
lib LibMPR
  fun WNetAddConnection4W = WNetAddConnection4W(
    hwndOwner : Void*,   # HWND optional
    lpNetResource : NETRESOURCEW*,   # NETRESOURCEW*
    pAuthBuffer : Void*,   # void*
    cbAuthBuffer : UInt32,   # DWORD
    dwFlags : UInt32,   # NET_CONNECT_FLAGS
    lpUseOptions : UInt8*,   # BYTE*
    cbUseOptions : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WNetAddConnection4WNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint32, Uint32, Pointer<Uint8>, Uint32);
typedef WNetAddConnection4WDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, int, int, Pointer<Uint8>, int);
final WNetAddConnection4W = DynamicLibrary.open('MPR.dll')
    .lookupFunction<WNetAddConnection4WNative, WNetAddConnection4WDart>('WNetAddConnection4W');
// hwndOwner : HWND optional -> Pointer<Void>
// lpNetResource : NETRESOURCEW* -> Pointer<Void>
// pAuthBuffer : void* -> Pointer<Void>
// cbAuthBuffer : DWORD -> Uint32
// dwFlags : NET_CONNECT_FLAGS -> Uint32
// lpUseOptions : BYTE* -> Pointer<Uint8>
// cbUseOptions : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WNetAddConnection4W(
  hwndOwner: THandle;   // HWND optional
  lpNetResource: Pointer;   // NETRESOURCEW*
  pAuthBuffer: Pointer;   // void*
  cbAuthBuffer: DWORD;   // DWORD
  dwFlags: DWORD;   // NET_CONNECT_FLAGS
  lpUseOptions: Pointer;   // BYTE*
  cbUseOptions: DWORD   // DWORD
): DWORD; stdcall;
  external 'MPR.dll' name 'WNetAddConnection4W';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WNetAddConnection4W"
  c_WNetAddConnection4W :: Ptr () -> Ptr () -> Ptr () -> Word32 -> Word32 -> Ptr Word8 -> Word32 -> IO Word32
-- hwndOwner : HWND optional -> Ptr ()
-- lpNetResource : NETRESOURCEW* -> Ptr ()
-- pAuthBuffer : void* -> Ptr ()
-- cbAuthBuffer : DWORD -> Word32
-- dwFlags : NET_CONNECT_FLAGS -> Word32
-- lpUseOptions : BYTE* -> Ptr Word8
-- cbUseOptions : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wnetaddconnection4w =
  foreign "WNetAddConnection4W"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> returning uint32_t)
(* hwndOwner : HWND optional -> (ptr void) *)
(* lpNetResource : NETRESOURCEW* -> (ptr void) *)
(* pAuthBuffer : void* -> (ptr void) *)
(* cbAuthBuffer : DWORD -> uint32_t *)
(* dwFlags : NET_CONNECT_FLAGS -> uint32_t *)
(* lpUseOptions : BYTE* -> (ptr uint8_t) *)
(* cbUseOptions : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mpr (t "MPR.dll"))
(cffi:use-foreign-library mpr)

(cffi:defcfun ("WNetAddConnection4W" wnet-add-connection4-w :convention :stdcall) :uint32
  (hwnd-owner :pointer)   ; HWND optional
  (lp-net-resource :pointer)   ; NETRESOURCEW*
  (p-auth-buffer :pointer)   ; void*
  (cb-auth-buffer :uint32)   ; DWORD
  (dw-flags :uint32)   ; NET_CONNECT_FLAGS
  (lp-use-options :pointer)   ; BYTE*
  (cb-use-options :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WNetAddConnection4W = Win32::API::More->new('MPR',
    'DWORD WNetAddConnection4W(HANDLE hwndOwner, LPVOID lpNetResource, LPVOID pAuthBuffer, DWORD cbAuthBuffer, DWORD dwFlags, LPVOID lpUseOptions, DWORD cbUseOptions)');
# my $ret = $WNetAddConnection4W->Call($hwndOwner, $lpNetResource, $pAuthBuffer, $cbAuthBuffer, $dwFlags, $lpUseOptions, $cbUseOptions);
# hwndOwner : HWND optional -> HANDLE
# lpNetResource : NETRESOURCEW* -> LPVOID
# pAuthBuffer : void* -> LPVOID
# cbAuthBuffer : DWORD -> DWORD
# dwFlags : NET_CONNECT_FLAGS -> DWORD
# lpUseOptions : BYTE* -> LPVOID
# cbUseOptions : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
類似 API
使用する型