|
Компьютерный форум OSzone.net » Автоматическая установка Windows » Автоматическая установка приложений » Скрипты Inno Setup. Помощь и советы [часть 5] |
|
Скрипты Inno Setup. Помощь и советы [часть 5]
|
Ветеран Сообщения: 1270 |
Профиль | Отправить PM | Цитировать
Внимание! Данная тема предназначена только для обсуждения написания скриптов !
Остальные вопросы, а также последние версии компилятора в теме Inno Setup. Прочие вопросы. Предыдущие ветки обсуждения по ссылкам ниже и в прикреплённых архивах: Inno Setup [все вопросы] часть 1 Inno Setup [все вопросы] часть 2 Скрипты Inno Setup. Помощь и советы [часть 3] Скрипты Inno Setup. Помощь и советы [часть 4] |
|
Отправлено: 03:49, 21-05-2012 |
Ветеран Сообщения: 649
|
Профиль | Отправить PM | Цитировать Respin, спасибо за ответ
первое Цитата Respin:
FreeArc - не то что нужно Цитата Respin:
переоформлю вопрос архиватор и есть библиотека, те все что делается через гуи делается через функции и импортированные из библиотеки. Мне хотелось бы импортировать основные возможности библиотеки и юзать их не прыгая с ветки на ветку (читай от левой библиотеки к левой) важны 1: Проресс 2: Параметры 3: Запаковка(не в большей мере) 4: возможность распаковки отдельного файла 5: вывод имени извлекаемого файла. короче то что мы делаем в архиваторе =================================================================== посоны помогите пожалуйста портировать код http://sendfile.su/695878 |
||
Последний раз редактировалось Johny777, 24-10-2012 в 20:24. Отправлено: 13:45, 24-10-2012 | #1181 |
Для отключения данного рекламного блока вам необходимо зарегистрироваться или войти с учетной записью социальной сети. Если же вы забыли свой пароль на форуме, то воспользуйтесь данной ссылкой для восстановления пароля. |
Ветеран Сообщения: 1270
|
Профиль | Отправить PM | Цитировать Цитата Johny777:
UPD: Реализовал callback. Мусор удален. UPD2: No problemo с кириллицей. UPD3: к черту неиспользуемые функции |
|
Последний раз редактировалось El Sanchez, 14-03-2013 в 15:34. Причина: update3 Отправлено: 17:01, 26-10-2012 | #1182 |
Ветеран Сообщения: 649
|
Профиль | Отправить PM | Цитировать El Sanchez, Слов нет, Спасибо!
думаю коду прямая дорога в шапку к остальным кодам Цитата El Sanchez:
Но всёж есть ли шанс реализовать в будущем? И кстати. Маленькая инфа функция SevenZipExtractArchive возвращает: 32800 - нажали на "отмену" 0 - распаковка завершена |
|
Отправлено: 22:14, 26-10-2012 | #1183 |
Ветеран Сообщения: 510
|
Профиль | Отправить PM | Цитировать можно ли сделать так,чтобы установщик запускался лишь на 7 и висте?
|
Отправлено: 23:56, 29-10-2012 | #1184 |
Ветеран Сообщения: 1640
|
Профиль | Отправить PM | Цитировать |
------- Отправлено: 03:58, 30-10-2012 | #1185 |
Забанен Сообщения: 158
|
|
Отправлено: 05:07, 30-10-2012 | #1186 |
Ветеран Сообщения: 1270
|
Профиль | Отправить PM | Цитировать Цитата Johny777:
|
|
Отправлено: 17:27, 30-10-2012 | #1187 |
Ветеран Сообщения: 1270
|
Профиль | Отправить PM | Цитировать Цитата Johny777:
|
|
Отправлено: 21:18, 30-10-2012 | #1188 |
Пользователь Сообщения: 57
|
Профиль | Отправить PM | Цитировать Доброго времени суток!
В первой процедуре создаю xml документ: oXMLDoc:= CreateOleObject('MSXML2.DOMDocument'); oXMLDoc.appendChild(oXMLDoc.createProcessingInstruction('xml', 'version="1.0" encoding="UTF-8"')); rootNode:= oXMLDoc.appendChild(oXMLDoc.createElement("CONFIG")); oXMLDoc.save("C:\test.xml"); xmlParser := CreateOleObject('Microsoft.XMLDOM'); xmlParser.async := False; xmlParser.load(fileName); rootElement:= xmlParser.getElementsByTagName("CONFIG"); for i := 0 to rootElement.length-1 do addElement:= rootElement.item[i].appendChild(xmlParser.createElement("Name")); xmlParser.save(fileName); <?xml version="1.0" encoding="UTF-8"?> <CONFIG><Name>/<Name></CONFIG> Подскажите можно как нить указать парсеру, что надо расставить переносы? |
Отправлено: 12:53, 31-10-2012 | #1189 |
Ветеран Сообщения: 649
|
Профиль | Отправить PM | Цитировать El Sanchez, ещё раз спасибо за код!
в общем добавил входной параметр OverwriteExistingFiles Извиняюсь за свой поспешный вывод о внесённых мной изменениях. всё работает! в функции SevenZipExtractArchive заменил TStringList на динамичный массив записей касательно куска кода if FileList = '' then FileList := '*.*'; как-то странно работало, те если мы указываем '' , то извлекаться должно все, но каталоги и файлы в них не извлекались, поэтому справил: if FileList[0] <> '' then for i := 0 to GetArrayLength(FileList)-1 do begin s7cmd := s7cmd + ' -i'; if RecurseFolders then s7cmd := s7cmd + 'r'; s7cmd := s7cmd + '!"' + RemoveQuotes(FileList[i]) + '"'; end; с тех пор как добавил "Отмену" (еще до внесения мной изменений) часто вылетает ошибка без выделения строки в дебаггере "Out Of Range" Я не знаю как исправить . Прошу помочь (хочу весь свой инсталл перевести на внешние архивы 7зип), а невозможность отменить распаковку от 4 до 16 гигив (в зависимости от выбора "компонентов") - это жесть И ещё просьба! есть вывод ei.dwFileSize, ei.dwWriteSize их ведь можно использовать для вывода второго прогрессбара, на котором будет отображаться прогресс распаковки текущего файла было бы здорово реализовать. В общем прошу помочь мне и в этом. Всё это мне не к спеху вот модифицированный код: ;El Sanchez, Реализовал callback. Мусор удален. Работает на ANSI/Unicode (Restools). [Setup] AppName=My Program AppVerName=My Program v.1.2 DefaultDirName={pf}\My Program [Files] Source: 7-zip32.dll; Flags: ignoreversion dontcopy nocompression solidbreak sortfilesbyextension [ code] #ifdef UNICODE #define A "W" #else #define A "A" #endif const // codes returned by SevenZipCreateArchive and SevenZipExtractArchive SZ_OK = 0; SZ_ERROR = 1; SZ_CANCELLED = 2; SZ_DLLERROR = 3; FNAME_MAX32 = 512; // these get returned as nState in the Callback function ARCEXTRACT_BEGIN = 0; ARCEXTRACT_INPROCESS = 1; ARCEXTRACT_END = 2; ARCEXTRACT_OPEN = 3; ARCEXTRACT_COPY = 4; // Errors ERROR_START = $8000; // WARNING ERROR_DISK_SPACE = $8005; ERROR_READ_ONLY = $8006; ERROR_USER_SKIP = $8007; ERROR_UNKNOWN_TYPE = $8008; ERROR_METHOD = $8009; ERROR_PASSWORD_FILE = $800A; ERROR_VERSION = $800B; ERROR_FILE_CRC = $800C; ERROR_FILE_OPEN = $800D; ERROR_MORE_FRESH = $800E; ERROR_NOT_EXIST = $800F; ERROR_ALREADY_EXIST = $8010; ERROR_TOO_MANY_FILES = $8011; // ERROR ERROR_MAKEDIRECTORY = $8012; ERROR_CANNOT_WRITE = $8013; ERROR_HUFFMAN_CODE = $8014; ERROR_COMMENT_HEADER = $8015; ERROR_HEADER_CRC = $8016; ERROR_HEADER_BROKEN = $8017; ERROR_ARC_FILE_OPEN = $8018; ERROR_NOT_ARC_FILE = $8019; ERROR_CANNOT_READ = $801A; ERROR_FILE_STYLE = $801B; ERROR_COMMAND_NAME = $801C; ERROR_MORE_HEAP_MEMORY = $801D; ERROR_ENOUGH_MEMORY = $801E; ERROR_ALREADY_RUNNING = $801F; ERROR_USER_CANCEL = $8020; ERROR_HARC_ISNOT_OPENED = $8021; ERROR_NOT_SEARCH_MODE = $8022; ERROR_NOT_SUPPORT = $8023; ERROR_TIME_STAMP = $8024; ERROR_TMP_OPEN = $8025; ERROR_LONG_FILE_NAME = $8026; ERROR_ARC_READ_ONLY = $8027; ERROR_SAME_NAME_FILE = $8028; ERROR_NOT_FIND_ARC_FILE = $8029; ERROR_RESPONSE_READ = $802A; ERROR_NOT_FILENAME = $802B; ERROR_TMP_COPY = $802C; ERROR_EOF = $802D; ERROR_ADD_TO_LARC = $802E; ERROR_TMP_BACK_SPACE = $802F; ERROR_SHARING = $8030; ERROR_NOT_FIND_FILE = $8031; ERROR_LOG_FILE = $8032; ERROR_NO_DEVICE = $8033; ERROR_GET_ATTRIBUTES = $8034; ERROR_SET_ATTRIBUTES = $8035; ERROR_GET_INFORMATION = $8036; ERROR_GET_POINT = $8037; ERROR_SET_POINT = $8038; ERROR_CONVERT_TIME = $8039; ERROR_GET_TIME = $803A; ERROR_SET_TIME = $803B; ERROR_CLOSE_FILE = $803C; ERROR_HEAP_MEMORY = $803D; ERROR_HANDLE = $803E; ERROR_TIME_STAMP_RANGE = $803F; ERROR_MAKE_ARCHIVE = $8040; ERROR_NOT_CONFIRM_NAME = $8041; ERROR_UNEXPECTED_EOF = $8042; ERROR_INVALID_END_MARK = $8043; ERROR_INVOLVED_LZH = $8044; ERROR_NO_END_MARK = $8045; ERROR_HDR_INVALID_SIZE = $8046; ERROR_UNKNOWN_LEVEL = $8047; ERROR_BROKEN_DATA = $8048; ERROR_7ZIP_START = $8100; ERROR_WARNING = $8101; ERROR_FATAL = $8102; ERROR_DURING_DECOMPRESSION = $8103; ERROR_DIR_FILE_WITH_64BIT_SIZE = $8104; ERROR_FILE_CHANGED_DURING_OPERATION = $8105; FA_RDONLY = $01; FA_HIDDEN = $02; FA_SYSTEM = $04; FA_LABEL = $08; FA_DIREC = $10; FA_ARCH = $20; FA_ENCRYPTED = $40; ARCHIVETYPE_ZIP = 1; ARCHIVETYPE_7Z = 2; WM_USER = $400; PBM_SETPOS = (WM_USER + 2); type HARC = Longint; INDIVIDUALINFO = record dwOriginalSize: DWORD; // Size of file. dwCompressedSize: DWORD; // Size after the compressing. dwCRC: DWORD; // For checksum CRC of file. uFlag: UINT; // With 7-zip32.dll always 0. uOSType: UINT; // OS which was used the occasion where the file is housed. Under present conditions always 0. wRatio: WORD; // Permill (thousand minute ratio) with the bulk compressibility which is displayed. In case of solid book room always 0. wDate: WORD; // Renewal date of file (DOS type). wTime: WORD; // Renewal time of file (DOS type). szFileName: array [0..FNAME_MAX32] of Byte; // Archive file name. dummy1: array [0..2] of Byte; szAttribute: array [0..7] of Byte; // Attribute of file. szMode: array [0..7] of Byte; // With 7-zip32.dll the character string of compressed system houses. end; EXTRACTINGINFO = record dwFileSize: DWORD; // Size of all the housing files. When entire size 0xFFFFFFFF (-1) it is above, 0xFFFFFFFF (-1) it houses. dwWriteSize: DWORD; // The entire size which processed with compression thawing processing. When dwFileSize 0xFFFFFFFF (-1) is, entire processing ratio (permill) it houses. szSourceFileName: array [0..FNAME_MAX32] of Byte; // The housing file name which processes. dummy1: array [0..2] of Byte; szDestFileName: array [0..FNAME_MAX32] of Byte; // The path name which actually is written. dummy: array [0..2] of Byte; end; EXTRACTINGINFOEX = record exinfo: EXTRACTINGINFO; //The EXTRACTINGINFO structure is housed. dwCompressedSize: DWORD; //Compressed size of housing file. When compressed size 0xFFFFFFFF (-1) it is above, 0xFFFFFFFF (-1) it houses. dwCRC: DWORD; //Checksum of housing file. uOSType: UINT; //OS which was used the occasion where the file is housed. Under present conditions always 0. wRatio: WORD; //Permill (thousand minute ratio) with the bulk compressibility which is displayed. In case of solid book room always 0. wDate: WORD; //Renewal date of housing file (DOS type). wTime: WORD; //Renewal time of housing file (DOS type). szAttribute: array [0..7] of Byte; //Attribute of housing file. szMode: array [0..7] of Byte; //With 7-zip32.dll the character string of compressed system houses. end; EXTRACTINGINFOEX32 = record dwStructSize: DWORD; //Size of structure. exinfo: EXTRACTINGINFO; //The EXTRACTINGINFO structure is housed. It just is left because of compatibility dwFileSize: DWORD; //Size of all the housing files. When entire size 0xFFFFFFFF (-1) it is above, 0xFFFFFFFF (-1) it houses. dwCompressedSize: DWORD; //Compressed size of housing file. When compressed size 0xFFFFFFFF (-1) it is above, 0xFFFFFFFF (-1) it houses. dwWriteSize: DWORD; //The entire size which processed with compression thawing processing. When dwFileSize 0xFFFFFFFF (-1) is, entire processing ratio (permill) it houses. dwAttributes: DWORD; //Attribute of housing file. dwCRC: DWORD; //Checksum of housing file. uOSType: UINT; //OS which was used the occasion where the file is housed. Under present conditions always 0. wRatio: WORD; //Permill (thousand minute ratio) with the bulk compressibility which is displayed. In case of solid book room always 0. ftCreateTime: TFileTime; //Compilation day and time of the file due to FILETIME type. ftAccessTime: TFileTime; //Reference day and time of the file due to FILETIME type. ftWriteTime: TFileTime; //Renewal day and time of the file due to FILETIME type. szMode: array [0..7] of Byte; //With 7-zip32.dll the character string of compressed system houses. szSourceFileName: array [0..FNAME_MAX32] of Byte; //The housing file name which processes. dummy1: array [0..2] of Byte; szDestFileName: array [0..FNAME_MAX32] of Byte; //The path name which actually is written. dummy2: array [0..2] of Byte; end; EXTRACTINGINFOEX64 = record dwStructSize: DWORD; //Size of structure exinfo: EXTRACTINGINFO; //The EXTRACTINGINFO structure is housed. It just is left because of compatibility. llFileSize: Extended; //Size of all the housing files. llCompressedSize: Extended; //Compressed size of housing file. llWriteSize: Extended; //The entire size which processed with compression thawing processing. dwAttributes: DWORD; //Attribute of housing file. dwCRC: DWORD; //Checksum of housing file. uOSType: UINT; //OS which was used the occasion where the file is housed. Under present conditions always 0. wRatio: WORD; //Permill (thousand minute ratio) with the bulk compressibility which is displayed. In case of solid book room always 0. ftCreateTime: TFileTime; //Compilation day and time of the file due to FILETIME type. ftAccessTime: TFileTime; //Reference day and time of the file due to FILETIME type. ftWriteTime: TFileTime; //Renewal day and time of the file due to FILETIME type. szMode: array [0..7] of Byte; //With 7-zip32.dll the character string of compressed system houses. szSourceFileName: array [0..FNAME_MAX32] of Byte; //The housing file name which processes. dummy1: array [0..2] of Byte; szDestFileName: array [0..FNAME_MAX32] of Byte; //The path name which actually is written. dummy2: array [0..2] of Byte; end; // Callback func should return FALSE to cancel the archiving process, else TRUE ARCHIVERPROC = function(_hwnd: HWND; _uMsg: UINT; _nState: UINT; _lpEis: Longint): BOOL; function SevenZip(const _hwnd: HWND; _szCmdLine: PAnsiChar; _szOutput: AnsiString; const _dwSize: DWORD): Integer; external 'SevenZip@files:7-zip32.dll stdcall'; function SevenZipGetVersion(): WORD; external 'SevenZipGetVersion@files:7-zip32.dll stdcall'; function SevenZipGetCursorMode(): BOOL; external 'SevenZipGetCursorMode@files:7-zip32.dll stdcall'; function SevenZipSetCursorMode(const _CursorMode: BOOL ): BOOL; external 'SevenZipSetCursorMode@files:7-zip32.dll stdcall'; //function SevenZipGetBackgroundMode(): BOOL; external 'SevenZipGetBackgroundMode@files:7-zip32.dll stdcall'; //function SevenZipSetBackgroundMode(const _BackGroundMode: BOOL): BOOL; external 'SevenZipSetBackgroundMode@files:7-zip32.dll stdcall'; function SevenZipGetCursorInterval(): WORD; external 'SevenZipGetCursorInterval@files:7-zip32.dll stdcall'; function SevenZipSetCursorInterval(const _CursorInterval: WORD): BOOL; external 'SevenZipSetCursorInterval@files:7-zip32.dll stdcall'; function SevenZipGetRunning(): BOOL; external 'SevenZipGetRunning@files:7-zip32.dll stdcall'; function SevenZipConfigDialog(const _hwnd: HWND; _szOptionBuffer: AnsiString; const _iMode: Integer): BOOL; external 'SevenZipConfigDialog@files:7-zip32.dll stdcall'; function SevenZipCheckArchive(_szFileName: PAnsiChar; const _iMode: Integer): BOOL; external 'SevenZipCheckArchive@files:7-zip32.dll stdcall'; function SevenZipGetArchiveType(_szFileName: PAnsiChar): Integer; external 'SevenZipGetArchiveType@files:7-zip32.dll stdcall'; function SevenZipGetFileCount(_szArcFile: PAnsiChar): Integer; external 'SevenZipGetFileCount@files:7-zip32.dll stdcall'; function SevenZipQueryFunctionList(const _iFunction: Integer): BOOL; external 'SevenZipQueryFunctionList@files:7-zip32.dll stdcall'; function SevenZipOpenArchive(const _hwnd: HWND; _szFileName: PAnsiChar; const _dwMode: DWORD): HARC; external 'SevenZipOpenArchive@files:7-zip32.dll stdcall'; function SevenZipCloseArchive(_harc: HARC): Integer; external 'SevenZipCloseArchive@files:7-zip32.dll stdcall'; function SevenZipFindFirst(_harc: HARC; _szWildName: PAnsiChar; var _lpSubInfo: INDIVIDUALINFO): Integer; external 'SevenZipFindFirst@files:7-zip32.dll stdcall'; function SevenZipFindNext(_harc: HARC; var _lpSubInfo: INDIVIDUALINFO): Integer; external 'SevenZipFindNext@files:7-zip32.dll stdcall'; function SevenZipGetArcFileName(_harc: HARC; _lpBuffer: PAnsiChar; _nSize: Integer): Integer; external 'SevenZipGetArcFileName@files:7-zip32.dll stdcall'; function SevenZipGetArcFileSize(_harc: HARC): DWORD; external 'SevenZipGetArcFileSize@files:7-zip32.dll stdcall'; function SevenZipGetArcOriginalSize(_harc: HARC): DWORD; external 'SevenZipGetArcOriginalSize@files:7-zip32.dll stdcall'; function SevenZipGetArcCompressedSize(_harc: HARC): DWORD; external 'SevenZipGetArcCompressedSize@files:7-zip32.dll stdcall'; function SevenZipGetArcRatio(_harc: HARC): WORD; external 'SevenZipGetArcRatio@files:7-zip32.dll stdcall'; function SevenZipGetArcDate(_harc: HARC): WORD; external 'SevenZipGetArcDate@files:7-zip32.dll stdcall'; function SevenZipGetArcTime(_harc: HARC): WORD; external 'SevenZipGetArcTime@files:7-zip32.dll stdcall'; function SevenZipGetArcOSType(_harc: HARC): UINT; external 'SevenZipGetArcOSType@files:7-zip32.dll stdcall'; function SevenZipIsSFXFile(_harc: HARC): Integer; external 'SevenZipIsSFXFile@files:7-zip32.dll stdcall'; function SevenZipGetFileName(_harc: HARC; _lpBuffer: PAnsiChar; _nSize: Integer): Integer; external 'SevenZipGetFileName@files:7-zip32.dll stdcall'; function SevenZipGetOriginalSize(_harc: HARC): DWORD; external 'SevenZipGetOriginalSize@files:7-zip32.dll stdcall'; function SevenZipGetCompressedSize(_harc: HARC): DWORD; external 'SevenZipGetCompressedSize@files:7-zip32.dll stdcall'; function SevenZipGetRatio(_harc: HARC): WORD; external 'SevenZipGetRatio@files:7-zip32.dll stdcall'; function SevenZipGetDate(_harc: HARC): WORD; external 'SevenZipGetDate@files:7-zip32.dll stdcall'; function SevenZipGetTime(_harc: HARC): WORD; external 'SevenZipGetTime@files:7-zip32.dll stdcall'; function SevenZipGetCRC(_harc: HARC): DWORD; external 'SevenZipGetCRC@files:7-zip32.dll stdcall'; function SevenZipGetAttribute(_harc: HARC): Integer; external 'SevenZipGetAttribute@files:7-zip32.dll stdcall'; function SevenZipGetOSType(_harc: HARC): UINT; external 'SevenZipGetOSType@files:7-zip32.dll stdcall'; function SevenZipGetMethod(_harc: HARC; _lpBuffer: AnsiString; const _nSize: Integer): Integer; external 'SevenZipGetMethod@files:7-zip32.dll stdcall'; function SevenZipGetWriteTime(_harc: HARC): DWORD; external 'SevenZipGetWriteTime@files:7-zip32.dll stdcall'; function SevenZipGetWriteTimeEx(_harc: HARC; var _lpftLastWriteTime: TFileTime): BOOL; external 'SevenZipGetWriteTimeEx@files:7-zip32.dll stdcall'; function SevenZipGetArcCreateTimeEx(_harc: HARC; var _lpftCreationTime: TFileTime): BOOL; external 'SevenZipGetArcCreateTimeEx@files:7-zip32.dll stdcall'; function SevenZipGetArcAccessTimeEx(_harc: HARC; var _lpftLastAccessTime: TFileTime): BOOL; external 'SevenZipGetArcAccessTimeEx@files:7-zip32.dll stdcall'; function SevenZipGetArcWriteTimeEx(_harc: HARC; var _lpftLastWriteTime: TFileTime): BOOL; external 'SevenZipGetArcWriteTimeEx@files:7-zip32.dll stdcall'; function SevenZipSetOwnerWindow(_hwnd: HWND): BOOL; external 'SevenZipSetOwnerWindow@files:7-zip32.dll stdcall'; function SevenZipClearOwnerWindow(): BOOL; external 'SevenZipClearOwnerWindow@files:7-zip32.dll stdcall'; function SevenZipSetOwnerWindowEx(_hwnd: HWND; _lpArcProc: Longint): BOOL; external 'SevenZipSetOwnerWindowEx@files:7-zip32.dll stdcall'; function SevenZipKillOwnerWindowEx(_hwnd: HWND): BOOL; external 'SevenZipKillOwnerWindowEx@files:7-zip32.dll stdcall'; function SevenZipSetOwnerWindowEx64(_hwnd: HWND; _lpArcProc: Longint; _dwStructSize: DWORD): BOOL; external 'SevenZipSetOwnerWindowEx64@files:7-zip32.dll stdcall'; function SevenZipKillOwnerWindowEx64(_hwnd: HWND): BOOL; external 'SevenZipKillOwnerWindowEx@files:7-zip32.dll stdcall'; function SevenZipGetSubVersion(): WORD; external 'SevenZipKillOwnerWindowEx64@files:7-zip32.dll stdcall'; function SevenZipGetArcFileSizeEx(_harc: HARC; var _lpllSize: Extended): BOOL; external 'SevenZipGetArcFileSizeEx@files:7-zip32.dll stdcall'; function SevenZipGetArcOriginalSizeEx(_harc: HARC; var _lpllSize: Extended): BOOL; external 'SevenZipGetArcOriginalSizeEx@files:7-zip32.dll stdcall'; function SevenZipGetArcCompressedSizeEx(_harc: HARC; var _lpllSize: Extended): BOOL; external 'SevenZipGetArcCompressedSizeEx@files:7-zip32.dll stdcall'; function SevenZipGetOriginalSizeEx(_harc: HARC; var _lpllSize: Extended): BOOL; external 'SevenZipGetOriginalSizeEx@files:7-zip32.dll stdcall'; function SevenZipGetCompressedSizeEx(_harc: HARC; var _lpllSize: Extended): BOOL; external 'SevenZipGetCompressedSizeEx@files:7-zip32.dll stdcall'; function SevenZipSetUnicodeMode(_bUnicode: BOOL): BOOL; external 'SevenZipSetUnicodeMode@files:7-zip32.dll stdcall'; // function RtlMoveMemory(var Destination: EXTRACTINGINFO; const Source: Longint; len: Integer): Integer; external 'RtlMoveMemory@kernel32.dll stdcall'; function SetWindowText(hWnd: HWND; lpString: String): BOOL; external 'SetWindowText{#A}@user32.dll stdcall'; function StrFormatByteSize64(qdw: Currency; var pszBuf: Char; cchBuf: UINT): PAnsiChar; external 'StrFormatByteSize64A@shlwapi.dll stdcall'; var szStatus: TNewStaticText; ei: EXTRACTINGINFO; ProgressPage: TOutputProgressWizardPage; hProgress, hMsg1Label, hMsg2Label: HWND; Cancel: boolean; function ByteArrayToString(cArray: array of Byte): String; begin Result := ''; while cArray[Length(Result)] <> 0 do Insert(Chr(cArray[Length(Result)]), Result, Length(Result)+1); end; function BytesToSize(Bytes: Extended): String; var pszBuf: array [0..15] of Char; begin try Result := StrFormatByteSize64(Abs(Bytes div 1E4), pszBuf[0], SizeOf(pszBuf)); except end; end; function ArchiverCallbackProc(_hwnd: HWND; _uMsg, _nState: UINT; _lpEis: Longint): BOOL; var dwCurrentSize: Single; begin Result := True; case _nState of ARCEXTRACT_BEGIN: SetWindowText(hMsg1Label, 'Status: scanning'); ARCEXTRACT_INPROCESS: begin // if Cancel then Exit; RtlMoveMemory(ei, _lpEis, SizeOf(ei)); dwCurrentSize := ei.dwWriteSize; PostMessage(hProgress, PBM_SETPOS, Round(65535*(dwCurrentSize/ei.dwFileSize)), 0); SetWindowText(hMsg1Label, 'Status: compressing'); SetWindowText(hMsg2Label, FormatFloat('Progress: 0.#0 %', (dwCurrentSize*100)/ei.dwFileSize)); SetWindowText(_hwnd, 'File: ' + ByteArrayToString(ei.szSourceFileName) + #13#10 + 'Total size: ' + BytesToSize(ei.dwFileSize) + #13#10 + 'Current size: ' + BytesToSize(ei.dwWriteSize)); Result := not Cancel; end; ARCEXTRACT_END: Result := False; ARCEXTRACT_OPEN: SetWindowText(hMsg1Label, 'Status: open archive'); end; end; procedure Cancel7ZipWork(Sender: TObject); begin Cancel := True; end; ///////////////////// procedure CreateSevenZipProgressPage; begin ProgressPage := CreateOutputProgressPage('7-zip', ''); szStatus := TNewStaticText.Create(ProgressPage); with szStatus do begin Parent := ProgressPage.Surface; WordWrap := True; SetBounds(ScaleX(0), ProgressPage.ProgressBar.Top + ScaleY(30), ProgressPage.Surface.Width, ScaleY(300)); end; with TButton.Create(nil) do begin Parent := ProgressPage.Surface; Caption := 'Cancel'; SetBounds(ScaleX(0), ProgressPage.ProgressBar.Top + ScaleY(90), ScaleX(75), ScaleY(25)); OnClick := @Cancel7ZipWork; end; end; ////////////////////////////////////////////////////// function SevenZipCreateArchive(hWnd: HWND; ArchiveFilename, BaseDirectory, FileList : String; CompressionLevel: Integer; CreateSolidArchive: Boolean; RecurseFolders: Boolean; Password, Sfx: String; ShowProgress: Boolean; Callback: Longint): Integer; var flist : TStringList; S7ResultOutput, s7cmd, cwd: AnsiString; i: Integer; begin Result := SZ_ERROR; if not SetCurrentDir(BaseDirectory) then Exit; // cwd := GetCurrentDir; flist := TStringList.Create; flist.CommaText := FileList; if Callback <> 0 then ShowProgress := False; try s7cmd := 'a "' + ArchiveFilename + '" "' + RemoveQuotes(flist.Strings[0]) + '"'; for i := 1 to flist.Count - 1 do begin s7cmd := s7cmd + ' -i'; if RecurseFolders then s7cmd := s7cmd + 'r'; s7cmd := s7cmd + '!"' + RemoveQuotes(flist.Strings[i]) + '"'; end; s7cmd := s7cmd + ' -mx' + IntToStr(CompressionLevel); if RecurseFolders then s7Cmd := s7cmd + ' -r'; if Password <> '' then s7Cmd := s7Cmd + ' -p' + Password; if CreateSolidArchive then s7cmd := s7cmd + ' -ms=on' else s7cmd := s7cmd + ' -ms=off'; if not ShowProgress then s7cmd := s7cmd + ' -hide'; if Length(Sfx) > 0 then s7cmd := s7cmd + ' -sfx' + Sfx; try s7ResultOutput := StringOfChar(#0, 10240); if Callback <> 0 then begin //get handles for 7-zip callback thread hProgress := ProgressPage.ProgressBar.Handle; hMsg1Label := ProgressPage.Msg1Label.Handle; hMsg2Label := ProgressPage.Msg2Label.Handle; //show progress page ProgressPage.Show; ProgressPage.ProgressBar.Show; ProgressPage.Description := 'Compress'; //set callback SevenZipSetOwnerWindowEx(hWnd, Callback); end; Result := SevenZip(hWnd, s7cmd, s7ResultOutput, Length(s7ResultOutput)-1); finally if Callback <> 0 then begin ProgressPage.Hide; SevenZipKillOwnerWindowEx(hWnd); end; //MsgBox(S7ResultOutput, mbInformation, MB_OK); except Result := SZ_DLLERROR; end; finally flist.Free; SetCurrentDir(cwd); end; end; ////////////////////////////////////////////////////// function SevenZipExtractArchive(hWnd: HWND; ArchiveFilename: String; FileList: TArrayOfString; RecurseFolders: Boolean; OverwriteExistingFiles: Boolean; Password: String; ExtractFullPaths: Boolean; ExtractBaseDir: String; ShowProgress: Boolean; Callback: Longint): Integer; var S7ResultOutput, s7cmd: AnsiString; i: Integer; begin Result := SZ_ERROR; if not FileExists(ArchiveFilename) then Exit; // //if FileList[0] = '' then FileList[0] := '*.*'; if Callback <> 0 then ShowProgress := False; if ExtractFullPaths then s7cmd := 'x' else s7cmd := 'e'; s7cmd := s7cmd + ' "' + ArchiveFilename + '" -o"' + ExtractBaseDir + '"'; // s7cmd := s7cmd + ' "' + FileList[0] + '"'; // if FileList[0] <> '' then for i := 0 to GetArrayLength(FileList)-1 do begin s7cmd := s7cmd + ' -i'; if RecurseFolders then s7cmd := s7cmd + 'r'; s7cmd := s7cmd + '!"' + RemoveQuotes(FileList[i]) + '"'; end; // if RecurseFolders then s7cmd := s7cmd + ' -r'; if Password <> '' then s7Cmd := s7Cmd + ' -p' + Password; if OverwriteExistingFiles then s7cmd := s7cmd + ' -aoa' else s7cmd := s7cmd + ' -aos'; if not ShowProgress then s7cmd := s7cmd + ' -hide'; s7cmd := s7cmd + ' -y'; try s7ResultOutput := StringOfChar(#0, 10240); if Callback <> 0 then begin //get handles for 7-zip callback thread hProgress := ProgressPage.ProgressBar.Handle; hMsg1Label := ProgressPage.Msg1Label.Handle; hMsg2Label := ProgressPage.Msg2Label.Handle; //show progress page ProgressPage.Show; ProgressPage.ProgressBar.Show; ProgressPage.Description := 'Extract'; //set callback SevenZipSetOwnerWindowEx(hWnd, Callback); end; Result := SevenZip(hWnd, s7cmd, S7ResultOutput, Length(s7ResultOutput)-1); finally if Callback <> 0 then begin ProgressPage.Hide; SevenZipKillOwnerWindowEx(hWnd); end; //MsgBox(S7ResultOutput, mbInformation, MB_OK); except Result := SZ_DLLERROR; end; end; procedure InitializeWizard(); begin Cancel := True; CreateSevenZipProgressPage; end; function NextButtonClick(CurPageID: Integer): Boolean; begin if CurPageID = wpWelcome then begin Cancel := False; // compress with callback //SevenZipCreateArchive(szStatus.Handle, 'C:\123.7z', 'c:\setup\se15', 'counter-strike.gcf', 1, True, False, '', '', False, CallbackAddr('ArchiverCallbackProc')); // compress without callback //SevenZipCreateArchive(szStatus.Handle, 'd:\123.7z', 'd:\', 'SkypeSetupFull.exe', 1, True, False, '', '', True, 0); // extract with callback SevenZipExtractArchive(szStatus.Handle, 'C:\hl1.VALVE', ['half-life high definition.gcf', 'se15\counter-strike.gcf'], False, True, '', True, 'c:\setup', False, CallbackAddr('ArchiverCallbackProc')); // extract with callback //SevenZipExtractArchive(szStatus.Handle, 'd:\123.7z', '', False, '', True, 'c:\', True, 0); Result := True; end; end; |
Последний раз редактировалось Johny777, 31-10-2012 в 16:44. Отправлено: 16:35, 31-10-2012 | #1190 |
Участник сейчас на форуме | Участник вне форума | Автор темы | Сообщение прикреплено |
| |||||
Название темы | Автор | Информация о форуме | Ответов | Последнее сообщение | |
Скрипты Inno Setup. Помощь и советы [часть 4] | El Sanchez | Автоматическая установка приложений | 2099 | 22-05-2012 23:16 | |
Скрипты Inno Setup. Помощь и советы [часть 3] | Serega | Автоматическая установка приложений | 3755 | 26-10-2011 17:58 | |
[архив] Скрипты Inno Setup. Помощь и советы [часть 2] | Serega | Автоматическая установка приложений | 2651 | 08-11-2010 18:34 | |
Скрипты Inno Setup Compiler | QAZAK | Автоматическая установка приложений | 7 | 15-01-2007 17:59 | |
Inno Setup | tradeukraine | Вебмастеру | 3 | 13-06-2006 20:39 |
|