当前位置:网站首页>C language calls the file browser to realize the effect of selecting files
C language calls the file browser to realize the effect of selecting files
2022-07-19 06:08:00 【Shining uncle】
c A program written in a language , Want to call the file browser of the system , Realize the effect of selecting files , You can use the following code
#include <ShlObj.h>
#include <windows.h>
TCHAR szPathName[MAX_PATH];
BROWSEINFO bInfo = {
0 };
bInfo.hwndOwner = GetForegroundWindow();// The parent window
bInfo.lpszTitle = TEXT(" Browse folders ");
//bInfo.pidlRoot=CSIDL_DRIVES;
bInfo.ulFlags = BIF_BROWSEINCLUDEFILES |BIF_EDITBOX/*| BIF_USENEWUI/* Contains an edit box Users can fill in the path manually The dialog box can be resized and so on ..*/ |
BIF_UAHINT/* belt TIPS Tips */ | BIF_NONEWFOLDERBUTTON/* Without the new folder button */;
LPITEMIDLIST lpDlist;
lpDlist = SHBrowseForFolder(&bInfo);
if (lpDlist != NULL)
{
SHGetPathFromIDList(lpDlist,szPathName);
MessageBox(NULL, szPathName, L"Dir Name", MB_OK);
// printf("%s",bInfo.pszDisplayName);
}
else
{
printf("user cancle\n");
}
Which USES BROWSEINFO structure
●BROWSEINFO Structure definition
typedef struct_browseinfo
{
undefined
HWND hwndOwner;
LPCITEMIDLIST pidlRoot;
LPSTR pszDisplayName;
LPCSTR lpszTitle;
UINT ulFlags;
BFFCALLBACK lpfn;
LPARAM lParam;
int iImage;
}BROWSEINFO,*PBROWSEINFO,*LPBROWSEINFO;
● BROWSEINFO Structure member variables
hwndOwner: Browse folder dialog parent Form handle .
pidlRoot:ITEMIDLIST Address of structure , Contains the initial root directory when browsing , And only the specified directory and its subdirectories are displayed in the Browse Folder dialog box . The Member variables can be NULL, At this time, the desktop directory will be used .
pszDisplayName: The memory address used to save the directory string selected by the user . The size of the buffer is defined by default MAX_PATH Constant macros .
lpszTitle: The displayed text of the Browse Folder dialog , Functions used to prompt the Browse Folder dialog 、 Role and purpose .
ulFlags: This flag bit describes the options of the dialog . It can be 0, It can also be the following Any combination of constants :
BIF_BROWSEFORCOMPUTER: Return computer name . Unless the user selects a computer name in the browser , Otherwise “OK” The button is gray .
BIF_BROWSEFORPRINTER: Return the printer name . Unless you select a printer name , otherwise “OK” The button is gray .
BIF_BROWSEINCLUDEFILES: The browser will display the directory , It also shows the file .
BIF_DONTGOBELOWDOMAIN: In the tree window , Does not include the network directory structure under the domain name .
BIF_EDITBOX: The browse dialog box contains an edit box , In this edit box, the user can enter the name of the selected item .
BIF_RETURNFSANCESTORS: Return to a node of the file system . Only when the selected node is a meaningful node ,“OK” Button can be used .
BIF_RETURNONLYFSDIRS: Just return the directory of the file system . for example : In the Browse Folder dialog , When any directory is selected , The “OK” Button available , And when selected “ My computer ” or “ Online neighbors ” When waiting for non meaningful nodes ,“OK” The button is gray .
BIF_STATUSTEXT: Include a status area in the dialog . Send a message to the dialog box to make The callback function sets the status text .
BIF_VALIDATE: When there is no BIF_EDITBOX When the flag bit , This flag bit is ignored . If the name entered by the user in the edit box is illegal , The browse dialog will send BFFM_VALIDATEFAILED Message to callback function .
lpfn: Application defined browse dialog The address of the callback function . When the event in the dialog box occurs , The dialog will call Callback function . This parameter can be used as NULL.
lParam: The dialog box is passed to A parameter of the callback function The pointer .
iImage: Images related to the selected directory . The image will be specified as the index value in the system image list .
边栏推荐
- Antd is not defined
- Unity2d learning Fox game production process 1: basic game character control, animation effects, lens control, item collection, bug optimization
- Material and application circuit diagram of 0-10V, 4-20mA current voltage to PWM isolation converter
- Dac7512n analog mixed signal IC converter
- Chrome浏览器设置 【显示右上角 翻译语言图标】
- Speed sensor signal isolation, acquisition and transformation, sine wave and sawtooth wave signal input, square wave signal output, signal converter
- Qt Creator闪退解决办法
- 3.7V lithium battery boost to 5v1a, fs2114 boost conversion chip design layout
- QTSS常数
- MySQL Workbench基本使用【创建一个数据库】
猜你喜欢

Qt Creator闪退解决办法

设置索引库结构,给用户添加可自动补全的suggestion,并将一些字段变成集合放到suggestion里面去

4-channel encoder pulse counter, 8-Channel do, Modbus TCP module

Configure the 'log' shortcut key in vscode and remove the console log(‘‘); Semicolon in;

Dac7512n analog mixed signal IC converter

结合图片看常用串口通信UART

4-20mA to 4-20mA 0-5V to 0-5V analog signal isolation transmitter

5-17陕西科技大学的隐藏学生服务

2022/07/12 学习笔记 (day05)循环

RestAPI实现自动补全 & 案例实现(搜索框输入进行自动补全)
随机推荐
DSL实现Metrics 聚合
4-20mA to 4-20mA 0-5V to 0-5V analog signal isolation transmitter
Triangle ranch (0/1 backpack)
HM agent multi section lithium battery charging IC
Tips for using tp4054 charging IC -- used in conjunction with Zhongke Lanxun ab5365b
Qt Creator闪退解决办法
XOR-gun (位运算,思维,区间暴力)
浅谈跨域的几种解决方案
DSL实现自动补全查询
c语言 指定日期开始多少天 显示
VSCode 即时英文翻译插件 【翻译(英汉词典)】
Boost dc/dc converter
三角形牧场 (0/1背包)
Thermal resistance PT100 cu50 isolation converter to 4-20mA analog output temperature transmitter 0-10V
5-17陕西科技大学的隐藏学生服务
MEX and Increments
单表查询、添加、更新与删除数据
Isolate 4-20mA or 0-20mA signal transmission
Baby Ehab partitions again (DP, construction, bit operation)
[transfer] Darwin streaming server core code analysis