ホーム › NetworkManagement.WNet › WNetConnectionDialog1A
WNetConnectionDialog1A
関数構造体を指定して接続ダイアログを表示する(ANSI版)。
シグネチャ
// MPR.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR WNetConnectionDialog1A(
CONNECTDLGSTRUCTA* lpConnDlgStruct
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpConnDlgStruct | CONNECTDLGSTRUCTA* | inout | 接続ダイアログの構成と結果を保持するCONNECTDLGSTRUCTA構造体へのポインタ。 |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// MPR.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR WNetConnectionDialog1A(
CONNECTDLGSTRUCTA* lpConnDlgStruct
);[DllImport("MPR.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint WNetConnectionDialog1A(
IntPtr lpConnDlgStruct // CONNECTDLGSTRUCTA* in/out
);<DllImport("MPR.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function WNetConnectionDialog1A(
lpConnDlgStruct As IntPtr ' CONNECTDLGSTRUCTA* in/out
) As UInteger
End Function' lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out
Declare PtrSafe Function WNetConnectionDialog1A 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
WNetConnectionDialog1A = ctypes.windll.mpr.WNetConnectionDialog1A
WNetConnectionDialog1A.restype = wintypes.DWORD
WNetConnectionDialog1A.argtypes = [
ctypes.c_void_p, # lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MPR.dll')
WNetConnectionDialog1A = Fiddle::Function.new(
lib['WNetConnectionDialog1A'],
[
Fiddle::TYPE_VOIDP, # lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out
],
-Fiddle::TYPE_INT)#[link(name = "mpr")]
extern "system" {
fn WNetConnectionDialog1A(
lpConnDlgStruct: *mut CONNECTDLGSTRUCTA // CONNECTDLGSTRUCTA* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MPR.dll", CharSet = CharSet.Ansi)]
public static extern uint WNetConnectionDialog1A(IntPtr lpConnDlgStruct);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MPR_WNetConnectionDialog1A' -Namespace Win32 -PassThru
# $api::WNetConnectionDialog1A(lpConnDlgStruct)#uselib "MPR.dll"
#func global WNetConnectionDialog1A "WNetConnectionDialog1A" sptr
; WNetConnectionDialog1A varptr(lpConnDlgStruct) ; 戻り値は stat
; lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MPR.dll" #cfunc global WNetConnectionDialog1A "WNetConnectionDialog1A" var ; res = WNetConnectionDialog1A(lpConnDlgStruct) ; lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MPR.dll" #cfunc global WNetConnectionDialog1A "WNetConnectionDialog1A" sptr ; res = WNetConnectionDialog1A(varptr(lpConnDlgStruct)) ; lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR WNetConnectionDialog1A(CONNECTDLGSTRUCTA* lpConnDlgStruct) #uselib "MPR.dll" #cfunc global WNetConnectionDialog1A "WNetConnectionDialog1A" var ; res = WNetConnectionDialog1A(lpConnDlgStruct) ; lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR WNetConnectionDialog1A(CONNECTDLGSTRUCTA* lpConnDlgStruct) #uselib "MPR.dll" #cfunc global WNetConnectionDialog1A "WNetConnectionDialog1A" intptr ; res = WNetConnectionDialog1A(varptr(lpConnDlgStruct)) ; lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mpr = windows.NewLazySystemDLL("MPR.dll")
procWNetConnectionDialog1A = mpr.NewProc("WNetConnectionDialog1A")
)
// lpConnDlgStruct (CONNECTDLGSTRUCTA* in/out)
r1, _, err := procWNetConnectionDialog1A.Call(
uintptr(lpConnDlgStruct),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction WNetConnectionDialog1A(
lpConnDlgStruct: Pointer // CONNECTDLGSTRUCTA* in/out
): DWORD; stdcall;
external 'MPR.dll' name 'WNetConnectionDialog1A';result := DllCall("MPR\WNetConnectionDialog1A"
, "Ptr", lpConnDlgStruct ; CONNECTDLGSTRUCTA* in/out
, "UInt") ; return: WIN32_ERROR●WNetConnectionDialog1A(lpConnDlgStruct) = DLL("MPR.dll", "dword WNetConnectionDialog1A(void*)")
# 呼び出し: WNetConnectionDialog1A(lpConnDlgStruct)
# lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mpr" fn WNetConnectionDialog1A(
lpConnDlgStruct: [*c]CONNECTDLGSTRUCTA // CONNECTDLGSTRUCTA* in/out
) callconv(std.os.windows.WINAPI) u32;proc WNetConnectionDialog1A(
lpConnDlgStruct: ptr CONNECTDLGSTRUCTA # CONNECTDLGSTRUCTA* in/out
): uint32 {.importc: "WNetConnectionDialog1A", stdcall, dynlib: "MPR.dll".}pragma(lib, "mpr");
extern(Windows)
uint WNetConnectionDialog1A(
CONNECTDLGSTRUCTA* lpConnDlgStruct // CONNECTDLGSTRUCTA* in/out
);ccall((:WNetConnectionDialog1A, "MPR.dll"), stdcall, UInt32,
(Ptr{CONNECTDLGSTRUCTA},),
lpConnDlgStruct)
# lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> Ptr{CONNECTDLGSTRUCTA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t WNetConnectionDialog1A(
void* lpConnDlgStruct);
]]
local mpr = ffi.load("mpr")
-- mpr.WNetConnectionDialog1A(lpConnDlgStruct)
-- lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MPR.dll');
const WNetConnectionDialog1A = lib.func('__stdcall', 'WNetConnectionDialog1A', 'uint32_t', ['void *']);
// WNetConnectionDialog1A(lpConnDlgStruct)
// lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MPR.dll", {
WNetConnectionDialog1A: { parameters: ["pointer"], result: "u32" },
});
// lib.symbols.WNetConnectionDialog1A(lpConnDlgStruct)
// lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t WNetConnectionDialog1A(
void* lpConnDlgStruct);
C, "MPR.dll");
// $ffi->WNetConnectionDialog1A(lpConnDlgStruct);
// lpConnDlgStruct : CONNECTDLGSTRUCTA* in/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 Mpr extends StdCallLibrary {
Mpr INSTANCE = Native.load("mpr", Mpr.class, W32APIOptions.ASCII_OPTIONS);
int WNetConnectionDialog1A(
Pointer lpConnDlgStruct // CONNECTDLGSTRUCTA* in/out
);
}@[Link("mpr")]
lib LibMPR
fun WNetConnectionDialog1A = WNetConnectionDialog1A(
lpConnDlgStruct : CONNECTDLGSTRUCTA* # CONNECTDLGSTRUCTA* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WNetConnectionDialog1ANative = Uint32 Function(Pointer<Void>);
typedef WNetConnectionDialog1ADart = int Function(Pointer<Void>);
final WNetConnectionDialog1A = DynamicLibrary.open('MPR.dll')
.lookupFunction<WNetConnectionDialog1ANative, WNetConnectionDialog1ADart>('WNetConnectionDialog1A');
// lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WNetConnectionDialog1A(
lpConnDlgStruct: Pointer // CONNECTDLGSTRUCTA* in/out
): DWORD; stdcall;
external 'MPR.dll' name 'WNetConnectionDialog1A';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WNetConnectionDialog1A"
c_WNetConnectionDialog1A :: Ptr () -> IO Word32
-- lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wnetconnectiondialog1a =
foreign "WNetConnectionDialog1A"
((ptr void) @-> returning uint32_t)
(* lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mpr (t "MPR.dll"))
(cffi:use-foreign-library mpr)
(cffi:defcfun ("WNetConnectionDialog1A" wnet-connection-dialog1-a :convention :stdcall) :uint32
(lp-conn-dlg-struct :pointer)) ; CONNECTDLGSTRUCTA* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WNetConnectionDialog1A = Win32::API::More->new('MPR',
'DWORD WNetConnectionDialog1A(LPVOID lpConnDlgStruct)');
# my $ret = $WNetConnectionDialog1A->Call($lpConnDlgStruct);
# lpConnDlgStruct : CONNECTDLGSTRUCTA* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f WNetConnectionDialog1W (Unicode版) — 構造体を指定して接続ダイアログを表示する(Unicode版)。
類似 API
- f WNetConnectionDialog — ネットワークリソース接続用の標準ダイアログを表示する。