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

DlgDirListComboBoxW

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

シグネチャ

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

INT DlgDirListComboBoxW(
    HWND hDlg,
    LPWSTR lpPathSpec,
    INT nIDComboBox,
    INT nIDStaticPath,
    DLG_DIR_LIST_FILE_TYPE uFiletype
);

パラメーター

名前方向
hDlgHWNDin
lpPathSpecLPWSTRinout
nIDComboBoxINTin
nIDStaticPathINTin
uFiletypeDLG_DIR_LIST_FILE_TYPEin

戻り値の型: INT

各言語での呼び出し定義

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

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

DlgDirListComboBoxW = ctypes.windll.user32.DlgDirListComboBoxW
DlgDirListComboBoxW.restype = ctypes.c_int
DlgDirListComboBoxW.argtypes = [
    wintypes.HANDLE,  # hDlg : HWND
    wintypes.LPWSTR,  # lpPathSpec : LPWSTR in/out
    ctypes.c_int,  # nIDComboBox : INT
    ctypes.c_int,  # nIDStaticPath : INT
    wintypes.DWORD,  # uFiletype : DLG_DIR_LIST_FILE_TYPE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
DlgDirListComboBoxW = Fiddle::Function.new(
  lib['DlgDirListComboBoxW'],
  [
    Fiddle::TYPE_VOIDP,  # hDlg : HWND
    Fiddle::TYPE_VOIDP,  # lpPathSpec : LPWSTR in/out
    Fiddle::TYPE_INT,  # nIDComboBox : 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 DlgDirListComboBoxW(
        hDlg: *mut core::ffi::c_void,  // HWND
        lpPathSpec: *mut u16,  // LPWSTR in/out
        nIDComboBox: 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, SetLastError = true)]
public static extern int DlgDirListComboBoxW(IntPtr hDlg, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpPathSpec, int nIDComboBox, int nIDStaticPath, uint uFiletype);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DlgDirListComboBoxW' -Namespace Win32 -PassThru
# $api::DlgDirListComboBoxW(hDlg, lpPathSpec, nIDComboBox, nIDStaticPath, uFiletype)
#uselib "USER32.dll"
#func global DlgDirListComboBoxW "DlgDirListComboBoxW" wptr, wptr, wptr, wptr, wptr
; DlgDirListComboBoxW hDlg, varptr(lpPathSpec), nIDComboBox, nIDStaticPath, uFiletype   ; 戻り値は stat
; hDlg : HWND -> "wptr"
; lpPathSpec : LPWSTR in/out -> "wptr"
; nIDComboBox : INT -> "wptr"
; nIDStaticPath : INT -> "wptr"
; uFiletype : DLG_DIR_LIST_FILE_TYPE -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global DlgDirListComboBoxW "DlgDirListComboBoxW" sptr, var, int, int, int
; res = DlgDirListComboBoxW(hDlg, lpPathSpec, nIDComboBox, nIDStaticPath, uFiletype)
; hDlg : HWND -> "sptr"
; lpPathSpec : LPWSTR in/out -> "var"
; nIDComboBox : INT -> "int"
; nIDStaticPath : INT -> "int"
; uFiletype : DLG_DIR_LIST_FILE_TYPE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT DlgDirListComboBoxW(HWND hDlg, LPWSTR lpPathSpec, INT nIDComboBox, INT nIDStaticPath, DLG_DIR_LIST_FILE_TYPE uFiletype)
#uselib "USER32.dll"
#cfunc global DlgDirListComboBoxW "DlgDirListComboBoxW" intptr, var, int, int, int
; res = DlgDirListComboBoxW(hDlg, lpPathSpec, nIDComboBox, nIDStaticPath, uFiletype)
; hDlg : HWND -> "intptr"
; lpPathSpec : LPWSTR in/out -> "var"
; nIDComboBox : 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")
	procDlgDirListComboBoxW = user32.NewProc("DlgDirListComboBoxW")
)

// hDlg (HWND), lpPathSpec (LPWSTR in/out), nIDComboBox (INT), nIDStaticPath (INT), uFiletype (DLG_DIR_LIST_FILE_TYPE)
r1, _, err := procDlgDirListComboBoxW.Call(
	uintptr(hDlg),
	uintptr(lpPathSpec),
	uintptr(nIDComboBox),
	uintptr(nIDStaticPath),
	uintptr(uFiletype),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function DlgDirListComboBoxW(
  hDlg: THandle;   // HWND
  lpPathSpec: PWideChar;   // LPWSTR in/out
  nIDComboBox: Integer;   // INT
  nIDStaticPath: Integer;   // INT
  uFiletype: DWORD   // DLG_DIR_LIST_FILE_TYPE
): Integer; stdcall;
  external 'USER32.dll' name 'DlgDirListComboBoxW';
result := DllCall("USER32\DlgDirListComboBoxW"
    , "Ptr", hDlg   ; HWND
    , "Ptr", lpPathSpec   ; LPWSTR in/out
    , "Int", nIDComboBox   ; INT
    , "Int", nIDStaticPath   ; INT
    , "UInt", uFiletype   ; DLG_DIR_LIST_FILE_TYPE
    , "Int")   ; return: INT
●DlgDirListComboBoxW(hDlg, lpPathSpec, nIDComboBox, nIDStaticPath, uFiletype) = DLL("USER32.dll", "int DlgDirListComboBoxW(void*, char*, int, int, dword)")
# 呼び出し: DlgDirListComboBoxW(hDlg, lpPathSpec, nIDComboBox, nIDStaticPath, uFiletype)
# hDlg : HWND -> "void*"
# lpPathSpec : LPWSTR in/out -> "char*"
# nIDComboBox : 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 版の利用を推奨。