Summary
This article provides InstallScript code that launches an HTML file from an installation using a Windows API call or the default browser on the target machine.Synopsis
This article provides InstallScript code that launches an HTML file from an installation using a Windows API call or the default browser on the target machine. For example, you can use this code to launch an HTML Readme file or direct your customers to register online.Discussion
A. Call the Windows API, ShellExecute, to open the HTML page. Below is a sample script that launches a file called iftw.htm from a local drive. To use this example, make a file called iftw.htm and put it in your C:\Windows\Temp directory. Place the following code in setup.rul. You can then call LaunchHTML in the OnFirstUIAfter event, for example, to launch your HTML file.
#define DLL_FILE "Shell32.DLL"
// Prototype ShellExecute in Shell32.DLL
prototype Shell32.ShellExecuteA(HWND, LPSTR, LPSTR, LPSTR, LPSTR, INT);
//prototype LaunchHTML function
prototype LaunchHTML();
//LaunchHTML() function
function LaunchHTML()
NUMBER nHwndFlag, nResult;
HWND hInstallHwnd;
STRING szOperation, szFile, szPath, szDLL, szParameter;
POINTER pszOperation, pszFile, pszPath, pszParameter;
begin
nHwndFlag = HWND_INSTALL;
//GetWindowHandle retrieves the handle of the installation main window
hInstallHwnd = GetWindowHandle(nHwndFlag);
//Load shell32.DLL into memory
szDLL = DLL_FILE;
nResult = UseDLL(szDLL);
if (nResult != 0) then
MessageBox("UseDLL failed.\n\nCouldn't load .DLL file.", INFORMATION);
abort;
endif;
szOperation="OPEN";
pszOperation=&szOperation;
szFile="iftw.htm";
pszFile=&szFile;
szPath="C:\\Windows\\Temp";
pszPath=&szPath;
szParameter="";
pszParameter=&szParameter;
//The following removes the Shell32.dll from memory
ShellExecuteA(hInstallHwnd, pszOperation, pszFile, pszParameter, pszPath, SW_SHOWMAXIMIZED);
if (UnUseDLL (szDLL) < 0) then
MessageBox("UnUseDLL failed.\n\nDLL still in memory.", SEVERE);
endif;
end;
B. The following example script launches the default browser and goes to InstallShield's home page. This script determines if a Web browser is available on the end user's system and then looks in the registry key HKEY_CLASSES_ROOT\.htm and obtains the default value for this key.
Then, the path to the browser executable is retrieved. The InstallScript function LaunchAppAndWait is called to launch this executable, passing the name of the HTML file as the command-line parameter. Place the following code in setup.rul. You can then call LaunchBrowser, for example, in the OnFirstUIAfter event to launch your HTML file.
//prototype LaunchBrowser function prototype LaunchBrowser(); / /LaunchBrowser() function function LaunchBrowser() STRING szSite, szKey, szDir; STRING svValue, svReturnString1, svReturnString2; NUMBER nvType, nvSize; begin szSite="http://www.installshield.com/"; //Find the value in the registry under "HKey_Classes_Root\.htm" file //to see where the browser address is kept.
RegDBSetDefaultRoot(HKEY_CLASSES_ROOT);
RegDBGetKeyValueEx(".htm", "", nvType, svValue, nvSize);
//Append the return value to Shell\open\command
//to get the path to executable of the browser
szKey = svValue+"\\shell\\open\\command";
RegDBGetKeyValueEx(szKey, "", nvType, svValue, nvSize);
//Because the value in the command usually has %1 or other placeholders,
//we parse the path to get the directory first and then the file name
//(this way all the characters after the file name including the placeholder are removed)
ParsePath(svReturnString1, svValue, PATH);
ParsePath(svReturnString2, svValue, FILENAME_ONLY);
//Now append the .exe extension to the file name.
//If the browser is IE, the path contains an extra quote("").
//By removing the placeholder, we also removed the ending close quote("),
//but it still has the beginning opening quote ("),
//so you have to put and ending quote (" to make if a correct path.
//Netscape does not have the extra "" in the path.
szDir=svReturnString1^svReturnString2+".exe";
if ( svReturnString2 = "iexplore" ) then
szDir=svReturnString1^svReturnString2+".exe\"";
endif;
//Now the path to the browser is available.
//You can launch the browser and pass your .htm file as a parameter to it.
LaunchAppAndWait(szDir, szSite, NOWAIT);
end;
Related Articles
Launching an HTML File 3Number of Views Resolving Commander Installation or Upgrade Failures 685Number of Views Launching Your Application after Installation 5Number of Views Launching an Executable From a Subdirectory of SOURCEDIR 3Number of Views Unable to See or Access Mapped Path During Installation 14Number 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