Win32 API 日本語リファレンス
ホームUI.Controls › DlgDirListW

DlgDirListW

関数
ディレクトリ内容をダイアログのリストボックスに一覧表示する(Unicode版)。
DLLUSER32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

INT DlgDirListW(
    HWND hDlg,
    LPWSTR lpPathSpec,
    INT nIDListBox,
    INT nIDStaticPath,
    DLG_DIR_LIST_FILE_TYPE uFileType
);

パラメーター

名前方向
hDlgHWNDin
lpPathSpecLPWSTRinout
nIDListBoxINTin
nIDStaticPathINTin
uFileTypeDLG_DIR_LIST_FILE_TYPEin

戻り値の型: INT

各言語での呼び出し定義

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

INT DlgDirListW(
    HWND hDlg,
    LPWSTR lpPathSpec,
    INT nIDListBox,
    INT nIDStaticPath,
    DLG_DIR_LIST_FILE_TYPE uFileType
);
[DllImport("USER32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int DlgDirListW(
    IntPtr hDlg,   // HWND
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpPathSpec,   // LPWSTR in/out
    int nIDListBox,   // INT
    int nIDStaticPath,   // INT
    uint uFileType   // DLG_DIR_LIST_FILE_TYPE
);
<DllImport("USER32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DlgDirListW(
    hDlg As IntPtr,   ' HWND
    <MarshalAs(UnmanagedType.LPWStr)> lpPathSpec As System.Text.StringBuilder,   ' LPWSTR in/out
    nIDListBox As Integer,   ' INT
    nIDStaticPath As Integer,   ' INT
    uFileType As UInteger   ' DLG_DIR_LIST_FILE_TYPE
) As Integer
End Function
' hDlg : HWND
' lpPathSpec : LPWSTR in/out
' nIDListBox : INT
' nIDStaticPath : INT
' uFileType : DLG_DIR_LIST_FILE_TYPE
Declare PtrSafe Function DlgDirListW Lib "user32" ( _
    ByVal hDlg As LongPtr, _
    ByVal lpPathSpec As LongPtr, _
    ByVal nIDListBox As Long, _
    ByVal nIDStaticPath As Long, _
    ByVal uFileType 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

DlgDirListW = ctypes.windll.user32.DlgDirListW
DlgDirListW.restype = ctypes.c_int
DlgDirListW.argtypes = [
    wintypes.HANDLE,  # hDlg : HWND
    wintypes.LPWSTR,  # lpPathSpec : LPWSTR in/out
    ctypes.c_int,  # nIDListBox : INT
    ctypes.c_int,  # nIDStaticPath : INT
    wintypes.DWORD,  # uFileType : DLG_DIR_LIST_FILE_TYPE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
DlgDirListW = Fiddle::Function.new(
  lib['DlgDirListW'],
  [
    Fiddle::TYPE_VOIDP,  # hDlg : HWND
    Fiddle::TYPE_VOIDP,  # lpPathSpec : LPWSTR in/out
    Fiddle::TYPE_INT,  # nIDListBox : INT
    Fiddle::TYPE_INT,  # nIDStaticPath : INT
    -Fiddle::TYPE_INT,  # uFileType : DLG_DIR_LIST_FILE_TYPE
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "user32")]
extern "system" {
    fn DlgDirListW(
        hDlg: *mut core::ffi::c_void,  // HWND
        lpPathSpec: *mut u16,  // LPWSTR in/out
        nIDListBox: i32,  // INT
        nIDStaticPath: i32,  // INT
        uFileType: u32  // DLG_DIR_LIST_FILE_TYPE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Unicode)]
public static extern int DlgDirListW(IntPtr hDlg, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpPathSpec, int nIDListBox, int nIDStaticPath, uint uFileType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DlgDirListW' -Namespace Win32 -PassThru
# $api::DlgDirListW(hDlg, lpPathSpec, nIDListBox, nIDStaticPath, uFileType)
#uselib "USER32.dll"
#func global DlgDirListW "DlgDirListW" wptr, wptr, wptr, wptr, wptr
; DlgDirListW hDlg, varptr(lpPathSpec), nIDListBox, nIDStaticPath, uFileType   ; 戻り値は stat
; hDlg : HWND -> "wptr"
; lpPathSpec : LPWSTR in/out -> "wptr"
; nIDListBox : INT -> "wptr"
; nIDStaticPath : INT -> "wptr"
; uFileType : DLG_DIR_LIST_FILE_TYPE -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global DlgDirListW "DlgDirListW" sptr, var, int, int, int
; res = DlgDirListW(hDlg, lpPathSpec, nIDListBox, nIDStaticPath, uFileType)
; hDlg : HWND -> "sptr"
; lpPathSpec : LPWSTR in/out -> "var"
; nIDListBox : INT -> "int"
; nIDStaticPath : INT -> "int"
; uFileType : DLG_DIR_LIST_FILE_TYPE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT DlgDirListW(HWND hDlg, LPWSTR lpPathSpec, INT nIDListBox, INT nIDStaticPath, DLG_DIR_LIST_FILE_TYPE uFileType)
#uselib "USER32.dll"
#cfunc global DlgDirListW "DlgDirListW" intptr, var, int, int, int
; res = DlgDirListW(hDlg, lpPathSpec, nIDListBox, nIDStaticPath, uFileType)
; hDlg : HWND -> "intptr"
; lpPathSpec : LPWSTR in/out -> "var"
; nIDListBox : INT -> "int"
; nIDStaticPath : INT -> "int"
; uFileType : DLG_DIR_LIST_FILE_TYPE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procDlgDirListW = user32.NewProc("DlgDirListW")
)

// hDlg (HWND), lpPathSpec (LPWSTR in/out), nIDListBox (INT), nIDStaticPath (INT), uFileType (DLG_DIR_LIST_FILE_TYPE)
r1, _, err := procDlgDirListW.Call(
	uintptr(hDlg),
	uintptr(lpPathSpec),
	uintptr(nIDListBox),
	uintptr(nIDStaticPath),
	uintptr(uFileType),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function DlgDirListW(
  hDlg: THandle;   // HWND
  lpPathSpec: PWideChar;   // LPWSTR in/out
  nIDListBox: Integer;   // INT
  nIDStaticPath: Integer;   // INT
  uFileType: DWORD   // DLG_DIR_LIST_FILE_TYPE
): Integer; stdcall;
  external 'USER32.dll' name 'DlgDirListW';
result := DllCall("USER32\DlgDirListW"
    , "Ptr", hDlg   ; HWND
    , "Ptr", lpPathSpec   ; LPWSTR in/out
    , "Int", nIDListBox   ; INT
    , "Int", nIDStaticPath   ; INT
    , "UInt", uFileType   ; DLG_DIR_LIST_FILE_TYPE
    , "Int")   ; return: INT
●DlgDirListW(hDlg, lpPathSpec, nIDListBox, nIDStaticPath, uFileType) = DLL("USER32.dll", "int DlgDirListW(void*, char*, int, int, dword)")
# 呼び出し: DlgDirListW(hDlg, lpPathSpec, nIDListBox, nIDStaticPath, uFileType)
# hDlg : HWND -> "void*"
# lpPathSpec : LPWSTR in/out -> "char*"
# nIDListBox : INT -> "int"
# nIDStaticPath : INT -> "int"
# uFileType : DLG_DIR_LIST_FILE_TYPE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。