Page 1 of 1
How to detect an invalid drive letter
Posted: Wed Dec 03, 2008 12:04 am
by get101
During an install, a user decides to install to drive X:
Unfortunately drive X: does not exist on her PC.
How can I detect that she has chosen an invalid drive? Also, where would I put a message telling her the drive she chose was invalid?
Posted: Wed Dec 03, 2008 2:20 am
by ulrichard
Hi get101,
Call DLL Function kernel32.dll->GetDriveTypeA (get result into variable DriveType)
With that you also find out if it's a fixed or removable drive.
Rgds
Richard
Posted: Thu Dec 04, 2008 12:42 am
by get101
Hi Richard
Is this what you have in mind?
Code: Select all
Set Variable TARGETDRIVE to $TARGETDIR$
Extract Parent Drive: TARGETDRIVE
Set Variable DriveType to
Call DLL Function kernel32.dll->GetDriveTypeA (get result into variable DriveType)
MessageBox: DriveType, The drive type is: $DriveType$.
I must be missing a step because it didnt work for me.
I might have it in the wrong place. I put it after this:
Code: Select all
label: Main Install
Comment: Exit Setup if Wizard Loop cancelled
if Variable WIZARD Equals CANCEL
Terminate Installation
end
It also gave me a message: Unable to load plug-in library. Please rebuild your project and make sure all required plug-ins are installed. Not sure what is needed.
Code: Select all
~InstallAware Clipboard Data~
~MessageBox~
~{2E41E9BD-2B7E-4D11-BBC8-52874E3932F6}~
~DriveType~
~The drive type is: $DriveType$.~
~0~
~1~
~~
~Call DLL Function~
~{5A07160B-DD9E-411F-9570-21725F729DD4}~
~kernel32.dll,GetDriveTypeA,word,DriveType,"pointer to string",$TARGETDRIVE$,$~
~~mIDEFunc.dll\\mEXEFunc.dll~~
~Set Variable~
~{35A03DCC-0094-4675-B943-929A1C1851A1}~
~DriveType$MYAH$MYAH$FALSE~
~~
~Extract Path~
~{30A14F00-FF6F-4AE8-8666-D85F8C33A05A}~
~TARGETDRIVE~
~5~
~Set Variable~
~{8305A032-3246-4BA8-823D-EB2DCFCABB56}~
~TARGETDRIVE$MYAH$MYAH$FALSE~
~$TARGETDIR$~
Any thoughts?
Posted: Thu Dec 04, 2008 10:51 am
by ulrichard
Hi get101,
I also check for a couple of other things:
label: Destination Directory
Comment: The main installation directory
Display Dialog: destination, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
GoTo Label: Custom Setup
else
if Variable WIZARD Equals CANCEL
GoTo Label: Main Install
end
end
Set Variable TargetDrive to
Parse String $TARGETDIR$ into Variables TargetDrive and (Split at position 2 from start)
Comment: MFC doesn't support unc paths
if Variable TargetDrive Equals \\\ MessageBox: UNC Paths are not allowed
GoTo Label: Destination Directory
end
Comment: The Windows installer doesn't support subst'ed paths
Set Variable DosTarget to
Set Variable DllResult to
Call DLL Function kernel32.dll->QueryDosDeviceA (get result into variable DllResult)
if Variable DosTarget Contains \\??\ MessageBox: Subst Paths are not allowed
GoTo Label: Destination Directory
end
Comment: The server installation has to go onto a mapped network drive
if Variable INSTALL_TYPE Equals (Ignore Case) NETWORK
Set Variable DriveType to
Call DLL Function kernel32.dll->GetDriveTypeA (get result into variable DriveType)
...
I use the Wizzard loop only for the simplest installer projects.
If you do file new and take the "Basic setup" template, it creates a skeleton without the wizzard loop, that you can copy into your project. (The region "Setup user interview" is of interest here)
I got messages like "Unable to load plug-in library. " When I didn't check an option that I later wanted to use on the InstallAware installation.
Don't know for sure though.
Rgds
Richard
Posted: Thu Dec 04, 2008 8:30 pm
by get101
Thanks Richard
Very useful information. Appreciate your insight.
Regards
Cyril