ホーム › NetworkManagement.WNet › WNetConnectionDialog
WNetConnectionDialog
関数ネットワークリソース接続用の標準ダイアログを表示する。
シグネチャ
// MPR.dll
#include <windows.h>
WIN32_ERROR WNetConnectionDialog(
HWND hwnd,
DWORD dwType
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | ダイアログの親ウィンドウハンドル。 |
| dwType | DWORD | in | 対象リソース種別。通常はRESOURCETYPE_DISKを指定する。 |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// MPR.dll
#include <windows.h>
WIN32_ERROR WNetConnectionDialog(
HWND hwnd,
DWORD dwType
);[DllImport("MPR.dll", ExactSpelling = true)]
static extern uint WNetConnectionDialog(
IntPtr hwnd, // HWND
uint dwType // DWORD
);<DllImport("MPR.dll", ExactSpelling:=True)>
Public Shared Function WNetConnectionDialog(
hwnd As IntPtr, ' HWND
dwType As UInteger ' DWORD
) As UInteger
End Function' hwnd : HWND
' dwType : DWORD
Declare PtrSafe Function WNetConnectionDialog Lib "mpr" ( _
ByVal hwnd As LongPtr, _
ByVal dwType As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WNetConnectionDialog = ctypes.windll.mpr.WNetConnectionDialog
WNetConnectionDialog.restype = wintypes.DWORD
WNetConnectionDialog.argtypes = [
wintypes.HANDLE, # hwnd : HWND
wintypes.DWORD, # dwType : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MPR.dll')
WNetConnectionDialog = Fiddle::Function.new(
lib['WNetConnectionDialog'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
-Fiddle::TYPE_INT, # dwType : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "mpr")]
extern "system" {
fn WNetConnectionDialog(
hwnd: *mut core::ffi::c_void, // HWND
dwType: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MPR.dll")]
public static extern uint WNetConnectionDialog(IntPtr hwnd, uint dwType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MPR_WNetConnectionDialog' -Namespace Win32 -PassThru
# $api::WNetConnectionDialog(hwnd, dwType)#uselib "MPR.dll"
#func global WNetConnectionDialog "WNetConnectionDialog" sptr, sptr
; WNetConnectionDialog hwnd, dwType ; 戻り値は stat
; hwnd : HWND -> "sptr"
; dwType : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MPR.dll"
#cfunc global WNetConnectionDialog "WNetConnectionDialog" sptr, int
; res = WNetConnectionDialog(hwnd, dwType)
; hwnd : HWND -> "sptr"
; dwType : DWORD -> "int"; WIN32_ERROR WNetConnectionDialog(HWND hwnd, DWORD dwType)
#uselib "MPR.dll"
#cfunc global WNetConnectionDialog "WNetConnectionDialog" intptr, int
; res = WNetConnectionDialog(hwnd, dwType)
; hwnd : HWND -> "intptr"
; dwType : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mpr = windows.NewLazySystemDLL("MPR.dll")
procWNetConnectionDialog = mpr.NewProc("WNetConnectionDialog")
)
// hwnd (HWND), dwType (DWORD)
r1, _, err := procWNetConnectionDialog.Call(
uintptr(hwnd),
uintptr(dwType),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction WNetConnectionDialog(
hwnd: THandle; // HWND
dwType: DWORD // DWORD
): DWORD; stdcall;
external 'MPR.dll' name 'WNetConnectionDialog';result := DllCall("MPR\WNetConnectionDialog"
, "Ptr", hwnd ; HWND
, "UInt", dwType ; DWORD
, "UInt") ; return: WIN32_ERROR●WNetConnectionDialog(hwnd, dwType) = DLL("MPR.dll", "dword WNetConnectionDialog(void*, dword)")
# 呼び出し: WNetConnectionDialog(hwnd, dwType)
# hwnd : HWND -> "void*"
# dwType : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mpr" fn WNetConnectionDialog(
hwnd: ?*anyopaque, // HWND
dwType: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc WNetConnectionDialog(
hwnd: pointer, # HWND
dwType: uint32 # DWORD
): uint32 {.importc: "WNetConnectionDialog", stdcall, dynlib: "MPR.dll".}pragma(lib, "mpr");
extern(Windows)
uint WNetConnectionDialog(
void* hwnd, // HWND
uint dwType // DWORD
);ccall((:WNetConnectionDialog, "MPR.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32),
hwnd, dwType)
# hwnd : HWND -> Ptr{Cvoid}
# dwType : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t WNetConnectionDialog(
void* hwnd,
uint32_t dwType);
]]
local mpr = ffi.load("mpr")
-- mpr.WNetConnectionDialog(hwnd, dwType)
-- hwnd : HWND
-- dwType : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MPR.dll');
const WNetConnectionDialog = lib.func('__stdcall', 'WNetConnectionDialog', 'uint32_t', ['void *', 'uint32_t']);
// WNetConnectionDialog(hwnd, dwType)
// hwnd : HWND -> 'void *'
// dwType : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MPR.dll", {
WNetConnectionDialog: { parameters: ["pointer", "u32"], result: "u32" },
});
// lib.symbols.WNetConnectionDialog(hwnd, dwType)
// hwnd : HWND -> "pointer"
// dwType : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t WNetConnectionDialog(
void* hwnd,
uint32_t dwType);
C, "MPR.dll");
// $ffi->WNetConnectionDialog(hwnd, dwType);
// hwnd : HWND
// dwType : 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);
int WNetConnectionDialog(
Pointer hwnd, // HWND
int dwType // DWORD
);
}@[Link("mpr")]
lib LibMPR
fun WNetConnectionDialog = WNetConnectionDialog(
hwnd : Void*, # HWND
dwType : 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 WNetConnectionDialogNative = Uint32 Function(Pointer<Void>, Uint32);
typedef WNetConnectionDialogDart = int Function(Pointer<Void>, int);
final WNetConnectionDialog = DynamicLibrary.open('MPR.dll')
.lookupFunction<WNetConnectionDialogNative, WNetConnectionDialogDart>('WNetConnectionDialog');
// hwnd : HWND -> Pointer<Void>
// dwType : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WNetConnectionDialog(
hwnd: THandle; // HWND
dwType: DWORD // DWORD
): DWORD; stdcall;
external 'MPR.dll' name 'WNetConnectionDialog';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WNetConnectionDialog"
c_WNetConnectionDialog :: Ptr () -> Word32 -> IO Word32
-- hwnd : HWND -> Ptr ()
-- dwType : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wnetconnectiondialog =
foreign "WNetConnectionDialog"
((ptr void) @-> uint32_t @-> returning uint32_t)
(* hwnd : HWND -> (ptr void) *)
(* dwType : 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 ("WNetConnectionDialog" wnet-connection-dialog :convention :stdcall) :uint32
(hwnd :pointer) ; HWND
(dw-type :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WNetConnectionDialog = Win32::API::More->new('MPR',
'DWORD WNetConnectionDialog(HANDLE hwnd, DWORD dwType)');
# my $ret = $WNetConnectionDialog->Call($hwnd, $dwType);
# hwnd : HWND -> HANDLE
# dwType : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f WNetConnectionDialog1W — 構造体を指定して接続ダイアログを表示する(Unicode版)。
使用する型