Summary
Include a file browse dialog in an InstallScript project.Synopsis
Applies to InstallScript projects. The following article explains how to include a file browse dialog into your InstallScript project.
Discussion
A file browse dialog can be displayed during setup by calling the Windows API GetOpenFileNameA. Follow these steps to use this API in your installation script.
brwsdlg.h
brwsdlg.txt
(After downloading this file, change the file extenion to .rul.)
InstallShield 11, 10.5, X or DevStudio
- Open the Installation Designer view.
- Under Behavior and Logic, select InstallScript.
- Right-click on your setup.rul file and select Import Script File.
- Now insert the files brwsdlg.h and brwsdlg.rul into your project. Go to step 2 below.
Legacy Professional
- Insert the files brwsdlg.h and brwsdlg.rul into your project by clicking on the scripts tab. Right-click on your setup.rul file and select Import Files.
- Click on your setup.rul file to bring up your script in the right hand window and insert the following code to your script, after the #include "ifx.h" statement.
#include "brwsdlg.h"
#include "brwsdlg.rul"Add the following sample script to call the API to display the file browse dialog.
function OnBegin()
// FileBrowseDlg requires the szFile parameter be explicitly sized
// and that the size be passed as the second parameter.
STRING szFile[512], svDir, svFileList, svTemp;
NUMBER nResult, nReturn;
BOOL bMultiSel, bDerefLinks;
LIST listFiles;
begin
// If I want to support multiple selection, set bMultiSel to TRUE
// and pass in a valid string list.
bMultiSel = TRUE;
bDerefLinks = FALSE;
listFiles = ListCreate(STRINGLIST);
// Open the file browse dialog.
nResult = FileBrowseDlg( szFile, 512, "All files (*.*)\0*.txt\0\0", "Select File", "c:\\", bMultiSel, listFiles, bDerefLinks );
if nResult = 0 then
if bMultiSel then
// If I chose multiple selection, I must parse the info, which is stored
// in list. First item will be dir, all others are individual filenames.
nReturn = ListGetFirstString(listFiles, svTemp);
while nReturn != END_OF_LIST
svFileList = svFileList + svTemp + "\n";
nReturn = ListGetNextString(listFiles, svTemp);
endwhile;
MessageBox("Directory (first item) and selected files:\n\n" + svFileList, 0);
else
// No multiple selection, so a single file/path was set.
MessageBox("Selected file:\n\n" + szFile, 0);
endif;
endif;
ListDestroy(listFiles);
end;
Note: This is only a sample. You can call the above script from any InstallShield event, such as OnBegin or OnEnd, or a function that is called from an InstallShield event.
Additional Information
For information on how to include InstallScript in InstallScript MSI and Basic MSI projects, see the InstallShield Help Library topic Using InstallScript.
For further information on the GetOpenFileName() API, see the MSDN article GetOpenFileName Function.
Related Articles
Displaying a File Open Browse Dialog in a Basic MSI project 6Number of Views Hiding or Moving a Control in an InstallScript Project Dialog 4Number of Views Logging An InstallScript MSI Project 361Number of Views Logging an InstallScript Project 12Number of Views Convert a Basic MSI Project to an InstallScript Project 3Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago