文件选择 API

GetOpenFileName 显示打开文件对话框
GetSaveFileName 显示保存文件对话框

GetOpenFileName 函数

GetSaveFileName 函数

BOOL GetOpenFileName( LPOPENFILENAME lpofn )
BOOL GetSaveFileName( LPOPENFILENAME lpofn )
参数 描述
lpofn OPENFILENAME 结构地址

LPBROWSEINFO 结构

struct OPENFILENAME{
  DWORD lStructSize;
  HWND hwndOwner;
  HINSTANCE hInstance;
  LPCSTR lpstrFilter;
  LPSTR lpstrCustomFilter;
  DWORD nMaxCustFilter;
  DWORD nFilterIndex;
  LPSTR lpstrFile;
  DWORD nMaxFile;
  LPSTR lpstrFileTitle;
  DWORD nMaxFileTitle;
  LPSTR lpstrInitialDir;
  LPCSTR lpstrTitle;
  DWORD Flags;
  WORD nFileOffset;
  WORD nFileExtension;
  LPCSTR lpstrDefExt;
  DWORD lCustData;
  LPOFNHOOKPROC lpfnHook;
  LPCSTR lpTemplateName;
};
参数 描述
lStructSize 结构尺寸,sizeof(OPENFILENAME)
hwndOwner 父窗口句柄
hInstance 实例句柄
lpstrFilter 文件筛选
TEXT("EXE Files (.exe)\0*.exe;\0")TEXT("All Files (*.*)\0*.*;\0")
lpstrCustomFilter  
nMaxCustFilter  
nFilterIndex 默认文件筛选序号
lpstrFile 输出文件名缓冲区
nMaxFile 输出文件名缓冲区大小,一般为 MAX_PATH
lpstrFileTitle  
lpstrInitialDir  
lpstrTitle 对话框标题
Flags  
nFileOffset  
nFileExtension  
lpstrDefExt  
lCustData  
lpfnHook  
lpTemplateName