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

WNetDisconnectDialog1A

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

シグネチャ

// MPR.dll  (ANSI / -A)
#include <windows.h>

WIN32_ERROR WNetDisconnectDialog1A(
    DISCDLGSTRUCTA* lpConnDlgStruct
);

パラメーター

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

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

// MPR.dll  (ANSI / -A)
#include <windows.h>

WIN32_ERROR WNetDisconnectDialog1A(
    DISCDLGSTRUCTA* lpConnDlgStruct
);
[DllImport("MPR.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint WNetDisconnectDialog1A(
    IntPtr lpConnDlgStruct   // DISCDLGSTRUCTA*
);
<DllImport("MPR.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function WNetDisconnectDialog1A(
    lpConnDlgStruct As IntPtr   ' DISCDLGSTRUCTA*
) As UInteger
End Function
' lpConnDlgStruct : DISCDLGSTRUCTA*
Declare PtrSafe Function WNetDisconnectDialog1A Lib "mpr" ( _
    ByVal lpConnDlgStruct As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	mpr = windows.NewLazySystemDLL("MPR.dll")
	procWNetDisconnectDialog1A = mpr.NewProc("WNetDisconnectDialog1A")
)

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

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

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

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

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

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

関連項目

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