gpt4 book ai didi

inno-setup - 在运行安装程序时获取代码部分中的文件名作为输入?

转载 作者:行者123 更新时间:2023-12-04 04:53:20 28 4
gpt4 key购买 nike

const
GetFileExInfoStandard = $0;

type
FILETIME = record
LowDateTime: DWORD;
HighDateTime: DWORD;
end;

WIN32_FILE_ATTRIBUTE_DATA = record
FileAttributes: DWORD;
CreationTime: FILETIME;
LastAccessTime: FILETIME;
LastWriteTime: FILETIME;
FileSizeHigh: DWORD;
FileSizeLow: DWORD;
end;

SYSTEMTIME = record
Year: WORD;
Month: WORD;
DayOfWeek: WORD;
Day: WORD;
Hour: WORD;
Minute: WORD;
Second: WORD;
Milliseconds: WORD;
end;

function GetFileAttributesEx (
FileName: string;
InfoLevelId: DWORD;
var FileInformation: WIN32_FILE_ATTRIBUTE_DATA
): Boolean;
external 'GetFileAttributesExA@kernel32.dll stdcall';

function FileTimeToSystemTime(
FileTime: FILETIME;
var SystemTime: SYSTEMTIME
): Boolean;
external 'FileTimeToSystemTime@kernel32.dll stdcall';

procedure InitializeWizard();
var
FileInformation: WIN32_FILE_ATTRIBUTE_DATA;
SystemInfo: SYSTEMTIME;
begin
GetFileAttributesEx('C:\Users\Gangadhar\Desktop\white_plain.gif', GetFileExInfoStandard , FileInformation);

FileTimeToSystemTime(FileInformation.LastWriteTime, SystemInfo);

MsgBox(format('%2.2d-%2.2d-%4.4d', [SystemInfo.Day, SystemInfo.Month, SystemInfo.Year]), mbInformation, MB_OK);
end;

我正在使用 Inno setup 创建自定义安装程序,我需要它来向我的安装程序添加一些东西。
通过此代码,我可以找到文件的最后修改日期,但我想在运行安装程序时将文件名作为输入。
看这里

GetFileAttributesEx('C:\Users\Gangadhar\Desktop\white_plain.gif', GetFileExInfoStandard , FileInformation);

在此函数中,我将文件名作为参数传递。我想在运行安装程序时选择此文件名,就像选择目标文件夹向导一样,然后将该选定的文件名作为参数传递给上述函数。

任何帮助将不胜感激。
提前致谢

最佳答案

您正在寻找 GetOpenFileName 函数,它显示一个对话框,使用户可以选择现有文件。以下脚本显示了当用户离开欢迎页面时如何显示此对话框。如果用户取消文件选择,他们将停留在欢迎页面:

[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
var
FileName: String;
begin
// allow users to go through the wizard by default
Result := True;
// if the user is going to leave the welcome page, then...
if CurPageID = wpWelcome then
begin
// set the initial file name
FileName := '';
// open the file dialog; if the user cancels it, they will stay at
// the welcome page (I don't know if it's your intention though)
Result := GetOpenFileName('Select the file to check', FileName, '',
'GIF Files (*.gif)|*.gif|All Files|*.*', '');
// if the user selected a file, then do whatever you want with it
if Result then
begin
// you got the file name in FileName variable
end;
end;
end;

关于inno-setup - 在运行安装程序时获取代码部分中的文件名作为输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17102239/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com