rabbit2011
wind
wind85
wind8black
wind8gray
wind8green
wind8purple
水墨江南
黑色旋风
紫色梦幻
绿之印象
春意盎然
蓝色天空
UID:25099
UID:377
图片:2011-01-27_144013.png
[Setup]AppName=我的软件AppVerName=我的软件版本 1.5DefaultDirName=XXXDefaultGroupName=我的软件Compression=lzmaSolidCompression=trueDisableProgramGroupPage=trueUsePreviousGroup=falseShowLanguageDialog=noOutputBaseFilename=drivesOnly[Files]Source: feature.txt; DestDir: {app}[Messages]SelectDirBrowseLabel=若要继续,单击下一步。如果您希望选择另一个驱动,请在列表中选择。[Code]var // 驱动勾选 cbDrive : TComboBox; // 保持驱动器号的字符串的数组 DrvLetters: array of String;function GetDriveType( lpDisk: String ): Integer;external 'GetDriveTypeA@kernel32.dll stdcall';function GetLogicalDriveStrings( nLenDrives: LongInt; lpDrives: String ): Integer;external 'GetLogicalDriveStringsA@kernel32.dll stdcall';const DRIVE_UNKNOWN = 0; // 驱动类型无法断定 DRIVE_NO_ROOT_DIR = 1; // 根目录无效。例如没有任何卷已挂载于目录。DRIVE_REMOVABLE = 2; // 磁盘可以从驱动中移除 DRIVE_FIXED = 3; // 磁盘不能从驱动中移除 DRIVE_REMOTE = 4; // 驱动是个远程 (网络) 驱动。 DRIVE_CDROM = 5; // 这是一个 CD-ROM 驱动。 DRIVE_RAMDISK = 6; // 这是一个 RAM 驱动。// 要将磁盘类型转换为字符串的函数function DriveTypeString( dtype: Integer ): String;begin case dtype of DRIVE_NO_ROOT_DIR : Result := 'Root path invalid'; DRIVE_REMOVABLE : Result := 'Removable'; DRIVE_FIXED : Result := 'Fixed'; DRIVE_REMOTE : Result := 'Network'; DRIVE_CDROM : Result := 'CD-ROM'; DRIVE_RAMDISK : Result := 'Ram disk'; else Result := 'Unknown'; end;end;// 更改文件夹依照所选的驱动字母procedure cbDriveOnClick(Sender: TObject);begin WizardForm.DirEdit.Text := DrvLetters[ cbDrive.ItemIndex ] + UpperCase(ExpandConstant('ABC\XYZ\123')); // 要添加的文件夹end;procedure FillCombo();var n: Integer; drivesletters: String; lenletters: Integer; drive: String; disktype, posnull: Integer; sd: String;begin //get the system drive sd := UpperCase(ExpandConstant('{sd}')); //get all drives letters of system drivesletters := StringOfChar( ' ', 64 ); lenletters := GetLogicalDriveStrings( 63, drivesletters ); SetLength( drivesletters , lenletters ); drive := ''; n := 0; while ( (Length(drivesletters) > 0) ) do begin posnull := Pos( #0, drivesletters ); if posnull > 0 then begin drive:= UpperCase( Copy( drivesletters, 1, posnull - 1 ) ); // 获取磁盘的号码类型 disktype := GetDriveType( drive ); // 如果不是软盘才添加 if ( not ( disktype = DRIVE_REMOVABLE ) ) then begin cbDrive.Items.Add( drive + ' [' + DriveTypeString( disktype ) + ']' ) SetArrayLength(DrvLetters, N+1); DrvLetters[n] := drive; // 默认选择 C: 驱动 //if ( Copy(drive,1,2) = 'C:' ) then cbDrive.ItemIndex := n; // or default to system drive if ( Copy(drive,1,2) = sd ) then cbDrive.ItemIndex := n; n := n + 1; end; drivesletters := Copy( drivesletters, posnull+1, Length(drivesletters)); end; end; cbDriveOnClick( cbDrive );end;procedure InitializeWizard();begin // 创建驱动的勾选框 cbDrive:= TComboBox.Create(WizardForm.SelectDirPage); with cbDrive do begin Parent := WizardForm.DirEdit.Parent; Left := WizardForm.DirEdit.Left; Top := WizardForm.DirEdit.Top + WizardForm.DirEdit.Height * 2; Width := WizardForm.DirEdit.Width; Style := csDropDownList; end; // 隐藏浏览按钮 WizardForm.DirBrowseButton.Visible := false; // 文件夹的编辑框不必作为可编辑 WizardForm.DirEdit.Enabled := false; //使用驱动填满勾选框 FillCombo; // 设置事件当勾选出现变化 cbDrive.OnClick := @cbDriveOnClick;end;
图片:1089.gif