Пользователь
Сообщения: 54
Благодарности: 11
|
Профиль
|
Отправить PM
| Цитировать
Можете подсказать, почему у меня ошибка could not call proc?
Пытаюсь при запуске инсталлятора проверить установленную версию PowerShell и если она меньше 5.1, тогда скачивать и устанавливать её.
Вот такой сокращённый код:
Код скрипта
Код:
[Setup]
AppName=PowerShell
AppVersion=5.1
[Files]
Source: "embedded\ISSkin\ISSkinU.dll"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\ISSkin\Styles\{#Skin}.cjstyles"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\7z.dll"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\7z.exe"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\7z32.dll"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\7z32.exe"; DestDir: {tmp}; Flags: dontcopy
[Languages]
Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl"
[CustomMessages]
ru.Caution7064=На компьютере обнаружена устаревшая версия PowerShell.%nПосле установки программы будет произведено скачивание и установка обновления PowerShell 5.1 для Windows 7 64bit.%n%nПожалуйста, дождитесь завершения обновления!
[_Code]
procedure LoadSkin(lpszPath: String; lpszIniFileName: String); external 'LoadSkin@files:ISSkinU.dll stdcall';
procedure UnloadSkin(); external 'UnloadSkin@files:ISSkinU.dll stdcall';
function ShowWindow(hWnd: Integer; uType: Integer): Integer; external 'ShowWindow@user32.dll stdcall';
function IsWindowsVersionOrNewer(Major, Minor: Integer): Boolean;
var
Version: TWindowsVersion;
begin
GetWindowsVersionEx(Version);
Result := (Version.Major > Major) or ((Version.Major = Major) and (Version.Minor >= Minor));
end;
function IsWindows70OrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(6, 1); end;
function IsWindows80OrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(6, 2); end;
function IsWindows81OrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(6, 3); end;
function IsWindows10OrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(10,0); end;
function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('{#Skin}.cjstyles');
LoadSkin(ExpandConstant('{tmp}\{#Skin}.cjstyles'), 'normalmystyle.ini');
Result := True;
end;
// Скачиваем PowerShell 5.1 под нашу версию Windows и битность...
procedure InitializeWizard;
var
PSVersion: String;
begin
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine','PowerShellVersion', PSVersion);
if ExpandConstant(Copy(PSVersion,1,3)) < ExpandConstant('5.1') then
begin
if IsWin64 then
begin
idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip',ExpandConstant('{tmp}\Win7AndW2K8R2-KB3191566-x64.zip'),68076477); end else
if IsWindows80OrNewer and not IsWindows81OrNewer then begin MsgBox(ExpandConstant('{cm:Caution8064}'), mbInformation, MB_OK);
idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/W2K12-KB3191565-x64.msu',ExpandConstant('{tmp}\W2K12-KB3191565-x64.msu'),21585220); end else
if IsWindows81OrNewer and not IsWindows10OrNewer then begin MsgBox(ExpandConstant('{cm:Caution8164}'), mbInformation, MB_OK);
idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win8.1AndW2K12R2-KB3191564-x64.msu',ExpandConstant('{tmp}\Win8.1AndW2K12R2-KB3191564-x64.msu'),19878906); end;
idpDownloadAfter(wpReady);
end
else
begin
if IsWindows70OrNewer and not IsWindows80OrNewer then begin MsgBox(ExpandConstant('{cm:Caution7032}'), mbInformation, MB_OK);
idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7-KB3191566-x86.zip',ExpandConstant('{tmp}\Win7-KB3191566-x86.zip'),44821734); end else
if IsWindows81OrNewer and not IsWindows10OrNewer then begin MsgBox(ExpandConstant('{cm:Caution8132}'), mbInformation, MB_OK);
idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win8.1-KB3191564-x86.msu',ExpandConstant('{tmp}\Win8.1-KB3191564-x86.msu'),15231117); end;
idpDownloadAfter(wpReady);
end;
end;
end;
// Во время показа страницы загрузки открываем по умолчанию скрытые детали загрузки...
procedure CurPageChanged(CurPageID: Integer);
begin
if not IsWindows10OrNewer then
begin
if CurPageID = IDPForm.Page.ID then
begin
// Показать детали загрузки
idpShowDetails(True);
// Скрываем кнопку Подробно/Скрыть
IDPForm.DetailsButton.Visible := False;
end;
end;
end;
// Распаковываем ранее скачанный ZIP/MSU и запускаем установку...
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
begin
if CurStep = ssPostInstall then
begin
if IsWin64 then
begin
if FileExists(ExpandConstant('{tmp}\Win7AndW2K8R2-KB3191566-x64.zip')) then
begin
ExtractTemporaryFile('7z.exe');
ExtractTemporaryFile('7z.dll');
ShellExec('open',ExpandConstant('{tmp}\7z.exe'),ExpandConstant('x -y -oExtractedArchive ')+ExpandConstant('Win7AndW2K8R2-KB3191566-x64.zip'),'',SW_HIDE,ewWaitUntilTerminated,ResultCode);
ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\ExtractedArchive\Win7AndW2K8R2-KB3191566-x64.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
end;
if FileExists(ExpandConstant('{tmp}\W2K12-KB3191565-x64.msu')) then ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\W2K12-KB3191565-x64.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
if FileExists(ExpandConstant('{tmp}\Win8.1AndW2K12R2-KB3191564-x64.msu')) then ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\Win8.1AndW2K12R2-KB3191564-x64.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
end
else
begin
if FileExists(ExpandConstant('{tmp}\Win7-KB3191566-x86.zip')) then
begin
ExtractTemporaryFile('7z32.exe');
ExtractTemporaryFile('7z32.dll');
ShellExec('open',ExpandConstant('{tmp}\7z32.exe'),ExpandConstant('x -y -oExtractedArchive ')+ExpandConstant('Win7-KB3191566-x86.zip'),'',SW_HIDE,ewWaitUntilTerminated,ResultCode);
ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\ExtractedArchive\Win7-KB3191566-x86.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
end;
if FileExists(ExpandConstant('{tmp}\Win8.1-KB3191564-x86.msu')) then ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\Win8.1-KB3191564-x86.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
end;
end;
end;
procedure DeinitializeSetup();
begin
ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), 0);
UnloadSkin();
end;
Поясняю, ошибка возникает, когда я после скачивания PowerShell вставляю код открытия детализации "Показать" и скрытия кнопки "Скрыть" на странице скачивания.
Без этого кода всё работает нормально.
А при вставке кода, сразу ошибка, причём только при условия меньше или больше, а при равенстве условия сравнения версий, всё отрабатывает правильно.
Вот этот короткий код в скрипте:
Код в скрипте, приводящий к ошибке: "could not call proc"
Код:
// Во время показа страницы загрузки открываем по умолчанию скрытые детали загрузки...
procedure CurPageChanged(CurPageID: Integer);
begin
if not IsWindows10OrNewer then
begin
if CurPageID = IDPForm.Page.ID then
begin
// Показать детали загрузки
idpShowDetails(True);
// Скрываем кнопку Подробно/Скрыть
IDPForm.DetailsButton.Visible := False;
end;
end;
end;
|