На главную

On-line справка по Win32 API

Написать письмо
БЕСПЛАТНАЯ ежедневная online лотерея! Выигрывай каждый день БЕСПЛАТНО!
Список всех статей A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z | Скачать Вниз

Creating an Installation Program



An installation program typically has the following goals:

· To place files in the correct location.
· To notify the user if the installation program is replacing an existing file with a version that is significantly different ѕ for example, replacing a German-language file with an English-language file, or replacing a newer file with an older file.



When writing the installation program, the developer must have the following information for each file on the installation disk(s):

· The name and location of the file (referred to as the source file).
· The name of the equivalent file on the user's hard disk (referred to as the destination file). This name is usually the same as the filename on the installation disk.
· The sharing status of the file ѕ that is, whether the file is private to the application being installed or could be shared by multiple applications.



For each file on the installation disk(s), the installation program must, at a minimum, call the VerFindFile and VerInstallFile functions. These functions are described briefly in the following paragraphs.
The installation program can use VerFindFile with the destination-file name to determine where the file should be copied on the disk. This function can also be used to specify whether the file is private to the application or can be shared. If a problem occurs in finding the file, VerFindFile returns an error value. For example, if Windows is using the destination file, VerFindFile returns VFF_FILEINUSE. The installation program must notify the user of the problem and respond to the user's decision to continue or to end the installation.

VerInstallFile copies the source file to a temporary file in the directory specified by VerFindFile. If necessary, VerInstallFile expands the file by using the functions in the data decompression library.
VerInstallFile compares the version information of the temporary file to that of the destination file. If the two differ, VerInstallFile returns one or more error values. For example, it returns VIF_SRCOLD if the temporary file is older than the destination file and VIF_DIFFLANG if the files have different language identifiers or code-page values. The installation program must notify the user of the problem and respond to the user's decision to continue or to end the installation.

Some VerInstallFile errors are recoverable. That is, the installation program can call VerInstallFile again, specifying the VIFF_FORCEINSTALL option, to install the file regardless of the version conflict. If VerInstallFile returns VIF_TEMPFILE and the user chooses not to force the installation, the installation program should delete the temporary file.
VerInstallFile could encounter a nonrecoverable error when attempting to force installation, even though the error did not exist previously. For example, the file could be locked by another user before the installation program attempted to force installation. If an installation program attempts to force installation after a non-recoverable error, VerInstallFile fails. The installation program must contain routines to recover from this type of error.

The recommended solution is to display for all errors a common dialog box with the buttons Install, Skip, and Install All. (Another solution is a dialog box with the buttons Yes, Yes to All, Skip, and Cancel.) The Install All button should prevent the installation program from prompting the user about similar errors by including the VIFF_FORCEINSTALL option in all subsequent uses of VerInstallFile. For nonrecoverable errors, the Install and Install All buttons should be disabled.

To display a useful error message to the user, the installation program usually must retrieve information from the version resources of the conflicting files. The file installation library provides four functions the installation program can use for this purpose: GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, and VerLanguageName. GetFileVersionInfoSize returns the size of the version information. GetFileVersionInfo uses information retrieved by GetFileVersionInfoSize to retrieve a structure that contains the version information. VerQueryValue retrieves a specific member from that structure.

For example, if VerInstallFile returns the VIF_DIFFTYPE error, the installation program should use the GetFileVersionInfoSize, GetFileVersionInfo, and VerQueryValue functions on the temporary and destination files to obtain the general type of each file. If the languages of the files conflict, the installation program should also use VerLanguageName to translate the binary language identifier into a text representation of the language. (For example, 0x040C translates to the string "French.")

If VerInstallFile returns a file error, such as VIF_ACCESSVIOLATION, the installation program should use the GetLastError function to retrieve the most recent error value. The program should translate this value into an informative message to display to the user. The program must not yield control between the calls to VerInstallFile and GetLastError.


Пригласи друзей и счет твоего мобильника всегда будет положительным!
Предыдущая статья
 
Сайт Народ.Ру Интернет
Следующая статья
Пригласи друзей и счет твоего мобильника всегда будет положительным!

Создание Установки Программы



Установка программы обычно имеет следующие цели:

, Чтобы устанавливать файлы в правильной позиции.
, Чтобы уведомлять потребителя если установка программы заменяет существующий файл версией, которая значительно другая U например, заменяя Немецко -языковой файл Англо -языковым файлом, или заменяя новый файл более старым файлом.



При записи установки программы, разработчик должен иметь следующую информацию для каждого файла в установке диска(дисков):

Имя и позиция файла (именующий исходный файл).
Имя эквиалентного файла на жестком диске пользователя (именующий файл расположения). Это зовут обычно такой же как и filename в установке диска.
Использующий статус файла U то есть, независимо файл частный в приложении, устанавливанном или могло бы быть распространено многочисленными приложениями.



Для каждого файла в установке диска(дисков), установка программы должна, на минимуме, назвать VerFindFile и функции VerInstallFile. Эти функции описываются кратко в следующих параграфах.
Установка программы может использовать VerFindFile с расположеним-файловым именем, чтобы определяться где файл должен быть скопирован на диске. Эта функция может также использована, чтобы определять независимо файл частное в приложении или может быть распространена. Если проблема происходит в обнаружении файла, VerFindFile возвращает величину ошибки. Например, если Windows использует файл расположения, возврата VerFindFile VFF_FILEINUSE. Установка программы должна уведомить пользователь о проблеме и реагировать на решение пользователя, чтобы продолжать или, чтобы заканчивать установку.

VerInstallFile КОПИРУЕТ исходный файл во временный файл в директории определенном VerFindFile. Если необходимо, VerInstallFile расширяет файл используя функции в библиотеке декомпрессии данных.
VerInstallFile СРАВНИВАЕТ информацию версии временного файла с тем самым файлом расположения. Если два отличаются, VerInstallFile возвращает одна или более величин ошибки. Например, это возвращает VIF_SRCOLD если временный файл более стар чем файл расположения и VIF_DIFFLANG если файлы имеют другие языковые идентификаторы или кодовые-страничные величины. Установка программы должна уведомить пользователь о проблеме и реагировать на решение пользователя, чтобы продолжать или, чтобы заканчивать установку.

Некоторые ошибки VerInstallFile исправимые. То есть, установка программы может назвать VerInstallFile снова, определяющее опцию VIFF_FORCEINSTALL, чтобы устанавливать файл независимо от конфликта версии. Если возврат VerInstallFile VIF_TEMPFILE и выборы пользователя не, чтобы заставлять установку, установка программы должна удалить временный файл.
VerInstallFile МОГ БЫ столкнуться с ошибкой одноразового действия при попытке, чтобы заставлять установку, даже если ошибка не существовала прежде. Например, файл мог бы быть заперт другим пользователем перед установкой программы попытавшейся, чтобы заставлять установку. Если установка программы пытается заставлять установку после не-исправимой ошибки, VerInstallFile терпит неудачу. Установка программы должна содержать программы, чтобы восстанавливаться из этого типа ошибки.

Рекомендуемое решение должно отображаться для всех ошибок общего диалогового блока с кнопками Устанавливать, Пропускать, и Устанавливать Все. (Другое решение является диалоговым блоком с Да кнопок, Да Все, Пропуск, и Отмена.) Install Всей кнопки должна предохранить установку программы от указания пользователя об аналогичных ошибках включая опцию VIFF_FORCEINSTALL во всем последующем использовании VerInstallFile. Для ошибок одноразового действия, Install и Устанавливать Все кнопки должно быть выведено из строя.

Чтобы отображать полезное сообщение ошибки пользователю, установка программы обычно должна извлечь информацию из ресурсов версии противоречивых файлов. Файловая библиотека установки обеспечивает четыре функции установка программы может использовать с этой целью: GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue, и VerLanguageName. GetFileVersionInfoSize ВОЗВРАЩАЕТ размер информации версии. GetFileVersionInfo ИСПОЛЬЗУЕТ информацию извлеченную GetFileVersionInfoSize, чтобы извлекать структуру, которая содержит информацию версии. VerQueryValue ИЗВЛЕКАЕТ специфический элемент из этой структуры.

Например, если VerInstallFile возвращает ошибку VIF_DIFFTYPE, установка программы должна использовать GetFileVersionInfoSize, GetFileVersionInfo, и функции VerQueryValue во временных и файлах расположения, чтобы получать общий тип каждого файла. Если языки файлов противоречат, установка программы должна также использовать VerLanguageName, чтобы переводиться двоичный языковой идентификатор в текстовое представление языка. (Например, 0x040C переводится в строку "Французского.")

Если VerInstallFile возвращает файловую ошибку, как например, VIF_ACCESSVIOLATION, установка программы должна использовать функцию GetLastError, чтобы извлекать наиболее последнюю величину ошибки. Программа должна переводиться эту величину в информационное сообщение, чтобы отображаться пользователю. Программа не должна давать управление между вызовами на VerInstallFile и GetLastError.


Вверх Version 1.3, Oct 26 2010 © 2007, 2010, mrhx Вверх
 mrhx software  Русский перевод OpenGL  Русский перевод Win32 API
 
Используются технологии uCoz