杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1994|回复: 0

如何浏览文件

[复制链接]
发表于 2017-1-9 20:49:50 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. #ifdef Unicode
  2. #define A "W"
  3. #else
  4. #define A "A"
  5. #endif

  6. [Setup]
  7. AppName=BrowseFile
  8. AppVerName=BrowseFile
  9. DefaultDirName=BrowseFile
  10. DisableStartupPrompt=true
  11. Uninstallable=false
  12. Compression=bzip
  13. CreateAppDir=false
  14. DisableProgramGroupPage=true

  15. [Tasks]
  16. Name: askini; Description: 选择一个自定义 INI 文件; GroupDescription: 配置:

  17. [Code]
  18. type
  19.   TOpenFileName = record
  20.     lStructSize: Longint;
  21.     hwndOwner: Longint;
  22.     hInstance: Longint;
  23.     lpstrFilter: String;
  24.     lpstrCustomFilter: String;
  25.     nMaxCustFilter: Longint;
  26.     nFilterIndex: Longint;
  27.     lpstrFile: String;
  28.     nMaxFile: Longint;
  29.     lpstrFileTitle: String;
  30.     nMaxFileTitle: Longint;
  31.     lpstrInitialDir: String;
  32.     lpstrTitle: String;
  33.     Flags: Longint;
  34.     nFileOffset: Word;
  35.     nFileExtension: Word;
  36.     lpstrDefExt: String;
  37.     lCustData: Longint;
  38.     lpfnHook: Longint;
  39.     lpTemplateName: String;
  40.   end;

  41. function GetOpenFileName(var lpofn: TOpenFileName): Boolean; external
  42. 'GetOpenFileName{#A}@comdlg32.dll';

  43. Const OFN_HIDEREADONLY = $4;

  44. function NextButtonClick(CurPage: Integer): Boolean;
  45. var
  46.   F: TOpenFileName;
  47.   S: String;
  48.   z : char;
  49.   hwnd: Longint;
  50. begin
  51.   // by default go to next page
  52.   Result := true;
  53.   z := Chr(0);
  54.   hwnd := StrToInt(ExpandConstant('{wizardhwnd}'));
  55.   // if curpage is wpSelectTasks
  56.   if CurPage = wpSelectTasks then
  57.   begin
  58.     if IsTaskSelected('askini') then
  59. begin
  60.       // set defailt file
  61.       S := 'config.ini';
  62.       // get enough space
  63.       SetLength(S, 512);
  64.       // set wizard HWND as owner
  65.       F.hwndOwner := hwnd;
  66.       // set structure size
  67.       F.lStructSize := 76;
  68.       // set S buffer for filename
  69.       F.lpstrFile := S;
  70.       F.nMaxFile := Length(S);
  71.       // set dialog title
  72.       F.lpstrTitle := '选择配置文件';
  73.       // set filters
  74.       F.lpstrFilter := 'INI 文件 (*.ini)' + z + '*.ini' + z +
  75.                        '所有文件 (*.*)' + z + '*.*' + z + z ;
  76.       // set flags
  77.       F.Flags := OFN_HIDEREADONLY;
  78.       // set initial dir as system
  79.       F.lpstrInitialDir := ExpandConstant('{sys}');
  80.       if GetOpenFileName(F) then begin
  81.         MsgBox( '你选择的文件是:'+ #13#10 + #13#10 + S , mbInformation, MB_OK );
  82.         Result := true;
  83.       end
  84.       else
  85.        Result := false;
  86.     end;
  87.   end;
  88. end;
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-19 17:49 , Processed in 0.112908 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表