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

WNetDisconnectDialog1W

関数
構造体を指定して切断ダイアログを表示する(Unicode版)。
DLLMPR.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

WIN32_ERROR WNetDisconnectDialog1W(
    DISCDLGSTRUCTW* lpConnDlgStruct
);

パラメーター

名前方向説明
lpConnDlgStructDISCDLGSTRUCTW*in切断ダイアログの構成を保持するDISCDLGSTRUCTW構造体へのポインタ。

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR WNetDisconnectDialog1W(
    DISCDLGSTRUCTW* lpConnDlgStruct
);
[DllImport("MPR.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint WNetDisconnectDialog1W(
    IntPtr lpConnDlgStruct   // DISCDLGSTRUCTW*
);
<DllImport("MPR.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function WNetDisconnectDialog1W(
    lpConnDlgStruct As IntPtr   ' DISCDLGSTRUCTW*
) As UInteger
End Function
' lpConnDlgStruct : DISCDLGSTRUCTW*
Declare PtrSafe Function WNetDisconnectDialog1W Lib "mpr" ( _
    ByVal lpConnDlgStruct As LongPtr) 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

WNetDisconnectDialog1W = ctypes.windll.mpr.WNetDisconnectDialog1W
WNetDisconnectDialog1W.restype = wintypes.DWORD
WNetDisconnectDialog1W.argtypes = [
    ctypes.c_void_p,  # lpConnDlgStruct : DISCDLGSTRUCTW*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mpr = windows.NewLazySystemDLL("MPR.dll")
	procWNetDisconnectDialog1W = mpr.NewProc("WNetDisconnectDialog1W")
)

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

extern "mpr" fn WNetDisconnectDialog1W(
    lpConnDlgStruct: [*c]DISCDLGSTRUCTW // DISCDLGSTRUCTW*
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc WNetDisconnectDialog1W(
    lpConnDlgStruct: ptr DISCDLGSTRUCTW  # DISCDLGSTRUCTW*
): uint32 {.importc: "WNetDisconnectDialog1W", stdcall, dynlib: "MPR.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "mpr");
extern(Windows)
uint WNetDisconnectDialog1W(
    DISCDLGSTRUCTW* lpConnDlgStruct   // DISCDLGSTRUCTW*
);
ccall((:WNetDisconnectDialog1W, "MPR.dll"), stdcall, UInt32,
      (Ptr{DISCDLGSTRUCTW},),
      lpConnDlgStruct)
# lpConnDlgStruct : DISCDLGSTRUCTW* -> Ptr{DISCDLGSTRUCTW}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t WNetDisconnectDialog1W(
    void* lpConnDlgStruct);
]]
local mpr = ffi.load("mpr")
-- mpr.WNetDisconnectDialog1W(lpConnDlgStruct)
-- lpConnDlgStruct : DISCDLGSTRUCTW*
-- 構造体/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 WNetDisconnectDialog1W = lib.func('__stdcall', 'WNetDisconnectDialog1W', 'uint32_t', ['void *']);
// WNetDisconnectDialog1W(lpConnDlgStruct)
// lpConnDlgStruct : DISCDLGSTRUCTW* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MPR.dll", {
  WNetDisconnectDialog1W: { parameters: ["pointer"], result: "u32" },
});
// lib.symbols.WNetDisconnectDialog1W(lpConnDlgStruct)
// lpConnDlgStruct : DISCDLGSTRUCTW* -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t WNetDisconnectDialog1W(
    void* lpConnDlgStruct);
C, "MPR.dll");
// $ffi->WNetDisconnectDialog1W(lpConnDlgStruct);
// lpConnDlgStruct : DISCDLGSTRUCTW*
// 構造体/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 WNetDisconnectDialog1W(
        Pointer lpConnDlgStruct   // DISCDLGSTRUCTW*
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("mpr")]
lib LibMPR
  fun WNetDisconnectDialog1W = WNetDisconnectDialog1W(
    lpConnDlgStruct : DISCDLGSTRUCTW*   # DISCDLGSTRUCTW*
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WNetDisconnectDialog1WNative = Uint32 Function(Pointer<Void>);
typedef WNetDisconnectDialog1WDart = int Function(Pointer<Void>);
final WNetDisconnectDialog1W = DynamicLibrary.open('MPR.dll')
    .lookupFunction<WNetDisconnectDialog1WNative, WNetDisconnectDialog1WDart>('WNetDisconnectDialog1W');
// lpConnDlgStruct : DISCDLGSTRUCTW* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WNetDisconnectDialog1W(
  lpConnDlgStruct: Pointer   // DISCDLGSTRUCTW*
): DWORD; stdcall;
  external 'MPR.dll' name 'WNetDisconnectDialog1W';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WNetDisconnectDialog1W"
  c_WNetDisconnectDialog1W :: Ptr () -> IO Word32
-- lpConnDlgStruct : DISCDLGSTRUCTW* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wnetdisconnectdialog1w =
  foreign "WNetDisconnectDialog1W"
    ((ptr void) @-> returning uint32_t)
(* lpConnDlgStruct : DISCDLGSTRUCTW* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mpr (t "MPR.dll"))
(cffi:use-foreign-library mpr)

(cffi:defcfun ("WNetDisconnectDialog1W" wnet-disconnect-dialog1-w :convention :stdcall) :uint32
  (lp-conn-dlg-struct :pointer))   ; DISCDLGSTRUCTW*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WNetDisconnectDialog1W = Win32::API::More->new('MPR',
    'DWORD WNetDisconnectDialog1W(LPVOID lpConnDlgStruct)');
# my $ret = $WNetDisconnectDialog1W->Call($lpConnDlgStruct);
# lpConnDlgStruct : DISCDLGSTRUCTW* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

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