ホーム › UI.Controls › DlgDirSelectComboBoxExA
DlgDirSelectComboBoxExA
関数コンボボックスで選択中のファイルやディレクトリ名を取得する(ANSI版)。
シグネチャ
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL DlgDirSelectComboBoxExA(
HWND hwndDlg,
LPSTR lpString,
INT cchOut,
INT idComboBox
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwndDlg | HWND | in |
| lpString | LPSTR | out |
| cchOut | INT | in |
| idComboBox | INT | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll (ANSI / -A)
#include <windows.h>
BOOL DlgDirSelectComboBoxExA(
HWND hwndDlg,
LPSTR lpString,
INT cchOut,
INT idComboBox
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool DlgDirSelectComboBoxExA(
IntPtr hwndDlg, // HWND
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpString, // LPSTR out
int cchOut, // INT
int idComboBox // INT
);<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DlgDirSelectComboBoxExA(
hwndDlg As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPStr)> lpString As System.Text.StringBuilder, ' LPSTR out
cchOut As Integer, ' INT
idComboBox As Integer ' INT
) As Boolean
End Function' hwndDlg : HWND
' lpString : LPSTR out
' cchOut : INT
' idComboBox : INT
Declare PtrSafe Function DlgDirSelectComboBoxExA Lib "user32" ( _
ByVal hwndDlg As LongPtr, _
ByVal lpString As String, _
ByVal cchOut As Long, _
ByVal idComboBox As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DlgDirSelectComboBoxExA = ctypes.windll.user32.DlgDirSelectComboBoxExA
DlgDirSelectComboBoxExA.restype = wintypes.BOOL
DlgDirSelectComboBoxExA.argtypes = [
wintypes.HANDLE, # hwndDlg : HWND
wintypes.LPSTR, # lpString : LPSTR out
ctypes.c_int, # cchOut : INT
ctypes.c_int, # idComboBox : INT
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
DlgDirSelectComboBoxExA = Fiddle::Function.new(
lib['DlgDirSelectComboBoxExA'],
[
Fiddle::TYPE_VOIDP, # hwndDlg : HWND
Fiddle::TYPE_VOIDP, # lpString : LPSTR out
Fiddle::TYPE_INT, # cchOut : INT
Fiddle::TYPE_INT, # idComboBox : INT
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn DlgDirSelectComboBoxExA(
hwndDlg: *mut core::ffi::c_void, // HWND
lpString: *mut u8, // LPSTR out
cchOut: i32, // INT
idComboBox: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool DlgDirSelectComboBoxExA(IntPtr hwndDlg, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpString, int cchOut, int idComboBox);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DlgDirSelectComboBoxExA' -Namespace Win32 -PassThru
# $api::DlgDirSelectComboBoxExA(hwndDlg, lpString, cchOut, idComboBox)#uselib "USER32.dll"
#func global DlgDirSelectComboBoxExA "DlgDirSelectComboBoxExA" sptr, sptr, sptr, sptr
; DlgDirSelectComboBoxExA hwndDlg, varptr(lpString), cchOut, idComboBox ; 戻り値は stat
; hwndDlg : HWND -> "sptr"
; lpString : LPSTR out -> "sptr"
; cchOut : INT -> "sptr"
; idComboBox : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global DlgDirSelectComboBoxExA "DlgDirSelectComboBoxExA" sptr, var, int, int ; res = DlgDirSelectComboBoxExA(hwndDlg, lpString, cchOut, idComboBox) ; hwndDlg : HWND -> "sptr" ; lpString : LPSTR out -> "var" ; cchOut : INT -> "int" ; idComboBox : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global DlgDirSelectComboBoxExA "DlgDirSelectComboBoxExA" sptr, sptr, int, int ; res = DlgDirSelectComboBoxExA(hwndDlg, varptr(lpString), cchOut, idComboBox) ; hwndDlg : HWND -> "sptr" ; lpString : LPSTR out -> "sptr" ; cchOut : INT -> "int" ; idComboBox : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL DlgDirSelectComboBoxExA(HWND hwndDlg, LPSTR lpString, INT cchOut, INT idComboBox) #uselib "USER32.dll" #cfunc global DlgDirSelectComboBoxExA "DlgDirSelectComboBoxExA" intptr, var, int, int ; res = DlgDirSelectComboBoxExA(hwndDlg, lpString, cchOut, idComboBox) ; hwndDlg : HWND -> "intptr" ; lpString : LPSTR out -> "var" ; cchOut : INT -> "int" ; idComboBox : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL DlgDirSelectComboBoxExA(HWND hwndDlg, LPSTR lpString, INT cchOut, INT idComboBox) #uselib "USER32.dll" #cfunc global DlgDirSelectComboBoxExA "DlgDirSelectComboBoxExA" intptr, intptr, int, int ; res = DlgDirSelectComboBoxExA(hwndDlg, varptr(lpString), cchOut, idComboBox) ; hwndDlg : HWND -> "intptr" ; lpString : LPSTR out -> "intptr" ; cchOut : INT -> "int" ; idComboBox : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procDlgDirSelectComboBoxExA = user32.NewProc("DlgDirSelectComboBoxExA")
)
// hwndDlg (HWND), lpString (LPSTR out), cchOut (INT), idComboBox (INT)
r1, _, err := procDlgDirSelectComboBoxExA.Call(
uintptr(hwndDlg),
uintptr(lpString),
uintptr(cchOut),
uintptr(idComboBox),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DlgDirSelectComboBoxExA(
hwndDlg: THandle; // HWND
lpString: PAnsiChar; // LPSTR out
cchOut: Integer; // INT
idComboBox: Integer // INT
): BOOL; stdcall;
external 'USER32.dll' name 'DlgDirSelectComboBoxExA';result := DllCall("USER32\DlgDirSelectComboBoxExA"
, "Ptr", hwndDlg ; HWND
, "Ptr", lpString ; LPSTR out
, "Int", cchOut ; INT
, "Int", idComboBox ; INT
, "Int") ; return: BOOL●DlgDirSelectComboBoxExA(hwndDlg, lpString, cchOut, idComboBox) = DLL("USER32.dll", "bool DlgDirSelectComboBoxExA(void*, char*, int, int)")
# 呼び出し: DlgDirSelectComboBoxExA(hwndDlg, lpString, cchOut, idComboBox)
# hwndDlg : HWND -> "void*"
# lpString : LPSTR out -> "char*"
# cchOut : INT -> "int"
# idComboBox : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。