Results 1 to 2 of 2

Thread: Inno Setup script help - selected drive D not working

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2014
    Posts
    3

    Inno Setup script help - selected drive D not working

    I'm trying to fix a bug in a script that I am using in the Inno Setup installer.

    The problem is that when I select the drive D radio button (from a list of drive C, drive D) the script wants to always install on drive C.

    I'm not that good at coding but in the GetDriveChoosed function, I saw that it was harded coded to always select drive C so I remmed out those lines but it still always selects drive C.

    Can someone help me figure out what I need to do to modify the code so I can select any available drive on my system?

    Thank you...

    Code:
     
    //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 ) );
    
          // get number type of disk
          disktype := GetDriveType( drive );
    
          // add it only if it is not a floppy
          if ( not ( disktype = DRIVE_REMOVABLE ) ) then
          begin
            SetArrayLength(DrivePrompts, N+1);
            SetArrayLength(DriveValues, N+1);
            SetArrayLength(DrvLetters, N+1);
    
            DrivePrompts[n] := drive + '  ' + DriveTypeString( disktype );
            DrvLetters[n] := drive;
            // default select C: Drive
            if ( drive = 'C:\' ) then DriveValues[n] := '1';
            n := n + 1;
          end
      drivesletters := Copy( drivesletters, posnull+1, Length(drivesletters));
      end
    end;
    
    
    function GetDriveChoosed : String;
    var i:Integer;
    begin
      for i:=0 to GetArrayLength(DriveValues)-1 do
        begin
          //if DriveValues[i]='1' then
          //  begin
              Result:=DrvLetters[i];
              Exit;
          //  end;
        end;
      Result:='?';
    end;

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,902

    Re: Inno Setup script help - selected drive D not working

    I'm no expert with inno setup and I'm fairly sure you haven't shown us the complete script but I think the problem might be that you've remmed out the if statement in GetDriveChoosed. That function is always going to return the first drive found.

    BTW, I've deleted your other thread as it was a duplicate of this one.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width