This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Using a .NET DLL in InstallShield
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 01, 2007
03:04 PM
Using a .NET DLL in InstallShield
I've done a few google searches, but I cannot find a definitive answer on how exactly the DLL should be written (whether to enable ComVisible or use System.Runtime.InteropServices, etc), nor how exactly to create the object. All help would be greatly appreciated, thanks!
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 01, 2007
05:18 PM
Are you talking about an installer DLL or writing custom actions in .NET?
With an installer DLL you need to inherit from the System.Configuration.Installer class and configure the component to use the class.
If you're writing custom actions in .NET you need to write your DLL in C++/CLI (.NET 2.0) or MC++ (.NET 1.1) so that you can export functions. Note that Microsoft states that .NET custom action DLL's are not supported but there are several people on this forum that have done it successfully.
With an installer DLL you need to inherit from the System.Configuration.Installer class and configure the component to use the class.
If you're writing custom actions in .NET you need to write your DLL in C++/CLI (.NET 2.0) or MC++ (.NET 1.1) so that you can export functions. Note that Microsoft states that .NET custom action DLL's are not supported but there are several people on this forum that have done it successfully.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 11, 2007
02:21 PM
how do you go about creating and using a dll for the install process to use.
I have a scenerio where I need to query a database and return 2 pieces of information to install shield and add say check box items to a dialog then based on what is checked have that dialog use another dll that will run another script and return maybe 5 pieces of information to installshield and then the installer could walk through like normal. Is this possible.
I have a scenerio where I need to query a database and return 2 pieces of information to install shield and add say check box items to a dialog then based on what is checked have that dialog use another dll that will run another script and return maybe 5 pieces of information to installshield and then the installer could walk through like normal. Is this possible.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 12, 2007
01:52 AM
Are you possibly looking for something like this?
http://community.installshield.com/showthread.php?t=168533
http://community.installshield.com/showthread.php?t=168533
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 12, 2007
11:19 AM
Yes this is similar to what I am wanting.
Ok I am new to installshield and C# so i did the dll and it compiles fine, then followed the steps in a new installscript/msi project loaded my new dll and the ISSQLSRV.dll into the support files, added the scripts to the setup.Rul and changed the build portion of the project, it throws me all kinds of errors. I am using InstallShield2008.
Here are the errors.
Here is my setup.Rul
[CODE]
//===========================================================================
//
// File Name: Setup.rul
//
// Description: Blank setup main script file
//
// Comments: Blank setup is an empty setup project. If you want to
// create a new project via. step-by step instructions use the
// Project Assistant.
//
//===========================================================================
// Included header files ----------------------------------------------------
#include "ifx.h"
// Note: In order to have your InstallScript function executed as a custom
// action by the Windows Installer, it must be prototyped as an
// entry-point function.
// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
/* export prototype MyFunction(HWND); */
prototype number DbConnectionCheck.Check(BYREF STRING, BYREF STRING, BYREF STRING, NUMBER);
prototype string DbConnectionCheck.GetErr();
set oObj = CoCreateObjectDotNet(SUPPORTDIR ^ "ISSupportSQL.dll", "DbConnectionCheck");
nRetVal = oObj.Check(sServer, sUser, sPassword, bWinAuth);
//---------------------------------------------------------------------------
// OnSQLLogin
//---------------------------------------------------------------------------
function number MyOnSQLLogin( nReturn, svTitle, svSubTitle )
string sDLL, sMessage;
string sHidden[MAX_PATH];
string sServer[MAX_PATH], sUser[MAX_PATH], sPassword[MAX_PATH], sAuth[10], sDB[MAX_PATH], sTemp[MAX_PATH];
number nResult, nSize, nRetVal;
BOOL bWinAuth, bDoneLogin;
string svDatabase, szErrMsg;
OBJECT oObj;
begin
svDatabase = "";
//First extract runtime dll
sDLL = SUPPORTDIR ^ "ISSQLSRV.DLL";
nResult = StreamFileFromBinary( ISMSI_HANDLE, "ISSQLSRV.DLL", sDLL );
UseDLL( sDLL );
//Get Default Properties
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_DIALOG", sTemp, nSize );
if( nSize > 0 ) then
//First add the Password property as a Hidden property
//so no passwords accidentally get logged.
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "MsiHiddenProperties", sHidden, nSize );
if( StrLength( sHidden ) > 0 ) then
sHidden = sHidden + ";" ;
endif;
sHidden = sHidden + "IS_SQLSERVER_PASSWORD";
MsiSetProperty( ISMSI_HANDLE, "MsiHiddenProperties", sHidden );
//Now get Default properties
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_SERVER", sServer, nSize );
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_USERNAME", sUser, nSize );
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_PASSWORD", sPassword, nSize );
nSize = 10;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_AUTHENTICATION", sAuth, nSize );
if( sAuth = "1" ) then
bWinAuth = FALSE;
else
bWinAuth = TRUE;
endif;
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_DATABASE", sDB, nSize );
//Now we have defaults
bDoneLogin = FALSE;
while( !bDoneLogin )
//Show login dialog
nReturn = mySQLServerSelectLogin( sServer, svDatabase, sUser, sPassword, bWinAuth, svTitle, svSubTitle );
if( nReturn = NEXT ) then
//place results from dialog in Property table
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_SERVER", sServer );
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_USERNAME", sUser );
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_PASSWORD", sPassword );
if( bWinAuth = TRUE ) then
sAuth = "0";
else
sAuth = "1";
endif;
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_AUTHENTICATION", sAuth );
//test connection
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_CA_SILENT", "0" );
set oObj = CoCreateObjectDotNet(SUPPORTDIR ^ "ISSupportSQL.dll", "DbConnectionCheck");
nRetVal = oObj.Check(sServer, sUser, sPassword, bWinAuth);
if( nRetVal != 0 ) then
szErrMsg = oObj.GetErr();
MessageBox( szErrMsg, MB_OK );
else
bDoneLogin = TRUE;
endif;
else
//BACK was clicked, so we don't even try
bDoneLogin = TRUE;
endif;
endwhile;
endif;
return nReturn;
end;
//---------------------------------------------------------------------------
// OnFirstUIBefore
//
// The OnFirstUIBefore event is called by the framework when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//---------------------------------------------------------------------------
function OnFirstUIBefore()
NUMBER nResult, nSetupType, nvSize, nUser;
STRING szTitle, szMsg, szQuestion, svName, svCompany, szFile;
STRING szLicenseFile;
LIST list, listStartCopy;
BOOL bCustom;
begin
// TO DO: if you want to enable background, window title, and caption bar title
// SetTitle( @PRODUCT_NAME, 24, WHITE );
// SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );
// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));
SHELL_OBJECT_FOLDER = @PRODUCT_NAME;
nSetupType = TYPICAL;
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome(szTitle, szMsg);
if (nResult = BACK) goto Dlg_SdWelcome;
szTitle = "";
svName = "";
svCompany = "";
Dlg_FirstSQL:
nResult = MyOnSQLLogin(nResult, "First SQL instance", "");
if( nResult = BACK ) then
goto Dlg_ChooseSqlInstances;
endif;
Dlg_SdCustomerInformation:
nResult = SdCustomerInformation(szTitle, svName, svCompany, nUser);
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SetupType:
szTitle = "";
szMsg = "";
nResult = SetupType(szTitle, szMsg, "", nSetupType, 0);
if (nResult = BACK) then
goto Dlg_SdCustomerInformation;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
nvSize = 0;
FeatureCompareSizeRequired(MEDIA, INSTALLDIR, nvSize);
if (nvSize != 0) then
MessageBox(szSdStr_NotEnoughSpace, WARNING);
goto Dlg_SetupType;
endif;
bCustom = FALSE;
goto Dlg_SQL;
else
bCustom = TRUE;
endif;
endif;
Dlg_SdAskDestPath:
nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
if (nResult = BACK) goto Dlg_SetupType;
Dlg_SdFeatureTree:
szTitle = "";
szMsg = "";
if (nSetupType = CUSTOM) then
nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2);
if (nResult = BACK) goto Dlg_SdAskDestPath;
endif;
Dlg_SQL:
nResult = OnSQLLogin( nResult );
if( nResult = BACK ) then
if (!bCustom) then
goto Dlg_SetupType;
else
goto Dlg_SdFeatureTree;
endif;
endif;
Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(svName) to a list(listStartCopy).
//eg. ListAddString(listStartCopy,svName,AFTER);
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);
if (nResult = BACK) then
goto Dlg_SQL;
endif;
// setup default status
Enable(STATUSEX);
return 0;
end;
//---------------------------------------------------------------------------
// OnSQLLogin
//---------------------------------------------------------------------------
function number OnSQLLogin( nBtn )
string sMessage;
string szConnection, szServer, szUser, szPassword, szDB, sTemp[MAX_PATH];
number nResult, nSize, nCount;
BOOL bWinLogin, bNext;
LIST listConnections;
begin
//First initialize SQL Server runtime
SQLRTInitialize2();
// Suppress ISSQLSRV.DLL to show a connection error message.
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_CA_SILENT", "1" );
//Get the names of all the necessary connections
listConnections = SQLRTGetConnections();
ListGetFirstString (listConnections, szConnection);
nCount = 0;
//determine if NEXT or BACK will be returned
//if there are no connections to make
if( nBtn != BACK ) then
bNext = TRUE;
else
bNext = FALSE;
//start at end if going BACK
while (ISERR_SUCCESS = ListGetNextString( listConnections, szConnection ) );
nCount++;
endwhile;
endif;
// Login for each connection
while (nResult = ISERR_SUCCESS)
//Get Default values for connection
SQLRTGetConnectionInfo( szConnection, szServer, szDB, szUser, szPassword );
bWinLogin = SQLRTGetConnectionAuthentication( szConnection );
// Display login dialog (without connection name)
// COMMENT OUT TO SWAP DIALOGS
nResult = SQLServerSelectLogin2( szConnection, szServer, szUser, szPassword, bWinLogin, szDB, FALSE, TRUE );
// Display login dialog (with connection name)
// UNCOMMENT TO SWAP DIALOGS
// nResult = SQLServerSelectLogin2( szConnection, szServer, szUser, szPassword, bWinLogin, szDB, TRUE, TRUE );
if( nResult = NEXT ) then
//store data in case we need it again
SQLRTPutConnectionInfo2( szConnection, szServer, szDB, szUser, szPassword );
SQLRTPutConnectionAuthentication( szConnection, bWinLogin );
//test connection
nResult = SQLRTTestConnection2( szConnection, szServer, szDB, szUser, szPassword, bWinLogin );
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_STATUS", sTemp, nSize );
if( sTemp != "0" ) then
nSize = _MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_STATUS_ERROR", sMessage, nSize );
if( nSize = 0 ) then
Sprintf(sMessage, SdLoadString( IDS_IFX_SQL_ERROR_LOGIN_FAILED ), szConnection, SdLoadString( ISCRIPT_E_UNKNOWN_ERROR_DESC ));
endif;
MessageBox( sMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
else //SUCCESS
//Move on to next connection
nCount++;
bNext = TRUE;
nResult = ListGetNextString(listConnections, szConnection);
endif;
else
//BACK
nCount--;
bNext = FALSE;
nResult = ListSetIndex( listConnections, nCount );
ListCurrentString( listConnections, szConnection );
endif;
endwhile;
if( bNext ) then
return NEXT;
else
return BACK;
endif;
end;
[/CODE]
Ok I am new to installshield and C# so i did the dll and it compiles fine, then followed the steps in a new installscript/msi project loaded my new dll and the ISSQLSRV.dll into the support files, added the scripts to the setup.Rul and changed the build portion of the project, it throws me all kinds of errors. I am using InstallShield2008.
Here are the errors.
Compiling...
Setup.Rul
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(29) : error C8019: 'set' : expected type declaration
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(29) : error C8022: '=' : comma or semicolon expected
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(29) : error C8008: 'DbConnectionCheck' : identifier expected
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(29) : error C8022: ')' : comma or semicolon expected
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(30) : error C8017: 'nRetVal' : expected typedef (struct) name
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(30) : error C8008: '=' : identifier expected
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(30) : error C8014: 'oObj' : identifier already defined
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(30) : error C8022: '.' : comma or semicolon expected
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(30) : error C8022: ')' : comma or semicolon expected
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(36) : error C8003: 'MyOnSQLLogin' : function has no prototype declaration
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(92) : error C8025: 'mySQLServerSelectLogin' : undefined identifier
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(92) : error C8041: '(' : function type required
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(135) : error C8087: cannot return value from program
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(173) : error C8025: 'MyOnSQLLogin' : undefined identifier
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(173) : error C8041: '(' : function type required
C:\InstallShield 2008 Projects\SQLTesting\Script Files\Setup.Rul(243) : error C8016: 'Dlg_ChooseSqlInstances' : undefined label:
Setup.inx - 16 error(s), 0 warning(s)
ISDEV : error -4370: There were errors compiling InstallScript
Here is my setup.Rul
[CODE]
//===========================================================================
//
// File Name: Setup.rul
//
// Description: Blank setup main script file
//
// Comments: Blank setup is an empty setup project. If you want to
// create a new project via. step-by step instructions use the
// Project Assistant.
//
//===========================================================================
// Included header files ----------------------------------------------------
#include "ifx.h"
// Note: In order to have your InstallScript function executed as a custom
// action by the Windows Installer, it must be prototyped as an
// entry-point function.
// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
/* export prototype MyFunction(HWND); */
prototype number DbConnectionCheck.Check(BYREF STRING, BYREF STRING, BYREF STRING, NUMBER);
prototype string DbConnectionCheck.GetErr();
set oObj = CoCreateObjectDotNet(SUPPORTDIR ^ "ISSupportSQL.dll", "DbConnectionCheck");
nRetVal = oObj.Check(sServer, sUser, sPassword, bWinAuth);
//---------------------------------------------------------------------------
// OnSQLLogin
//---------------------------------------------------------------------------
function number MyOnSQLLogin( nReturn, svTitle, svSubTitle )
string sDLL, sMessage;
string sHidden[MAX_PATH];
string sServer[MAX_PATH], sUser[MAX_PATH], sPassword[MAX_PATH], sAuth[10], sDB[MAX_PATH], sTemp[MAX_PATH];
number nResult, nSize, nRetVal;
BOOL bWinAuth, bDoneLogin;
string svDatabase, szErrMsg;
OBJECT oObj;
begin
svDatabase = "";
//First extract runtime dll
sDLL = SUPPORTDIR ^ "ISSQLSRV.DLL";
nResult = StreamFileFromBinary( ISMSI_HANDLE, "ISSQLSRV.DLL", sDLL );
UseDLL( sDLL );
//Get Default Properties
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_DIALOG", sTemp, nSize );
if( nSize > 0 ) then
//First add the Password property as a Hidden property
//so no passwords accidentally get logged.
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "MsiHiddenProperties", sHidden, nSize );
if( StrLength( sHidden ) > 0 ) then
sHidden = sHidden + ";" ;
endif;
sHidden = sHidden + "IS_SQLSERVER_PASSWORD";
MsiSetProperty( ISMSI_HANDLE, "MsiHiddenProperties", sHidden );
//Now get Default properties
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_SERVER", sServer, nSize );
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_USERNAME", sUser, nSize );
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_PASSWORD", sPassword, nSize );
nSize = 10;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_AUTHENTICATION", sAuth, nSize );
if( sAuth = "1" ) then
bWinAuth = FALSE;
else
bWinAuth = TRUE;
endif;
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_DATABASE", sDB, nSize );
//Now we have defaults
bDoneLogin = FALSE;
while( !bDoneLogin )
//Show login dialog
nReturn = mySQLServerSelectLogin( sServer, svDatabase, sUser, sPassword, bWinAuth, svTitle, svSubTitle );
if( nReturn = NEXT ) then
//place results from dialog in Property table
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_SERVER", sServer );
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_USERNAME", sUser );
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_PASSWORD", sPassword );
if( bWinAuth = TRUE ) then
sAuth = "0";
else
sAuth = "1";
endif;
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_AUTHENTICATION", sAuth );
//test connection
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_CA_SILENT", "0" );
set oObj = CoCreateObjectDotNet(SUPPORTDIR ^ "ISSupportSQL.dll", "DbConnectionCheck");
nRetVal = oObj.Check(sServer, sUser, sPassword, bWinAuth);
if( nRetVal != 0 ) then
szErrMsg = oObj.GetErr();
MessageBox( szErrMsg, MB_OK );
else
bDoneLogin = TRUE;
endif;
else
//BACK was clicked, so we don't even try
bDoneLogin = TRUE;
endif;
endwhile;
endif;
return nReturn;
end;
//---------------------------------------------------------------------------
// OnFirstUIBefore
//
// The OnFirstUIBefore event is called by the framework when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//---------------------------------------------------------------------------
function OnFirstUIBefore()
NUMBER nResult, nSetupType, nvSize, nUser;
STRING szTitle, szMsg, szQuestion, svName, svCompany, szFile;
STRING szLicenseFile;
LIST list, listStartCopy;
BOOL bCustom;
begin
// TO DO: if you want to enable background, window title, and caption bar title
// SetTitle( @PRODUCT_NAME, 24, WHITE );
// SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );
// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));
SHELL_OBJECT_FOLDER = @PRODUCT_NAME;
nSetupType = TYPICAL;
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome(szTitle, szMsg);
if (nResult = BACK) goto Dlg_SdWelcome;
szTitle = "";
svName = "";
svCompany = "";
Dlg_FirstSQL:
nResult = MyOnSQLLogin(nResult, "First SQL instance", "");
if( nResult = BACK ) then
goto Dlg_ChooseSqlInstances;
endif;
Dlg_SdCustomerInformation:
nResult = SdCustomerInformation(szTitle, svName, svCompany, nUser);
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SetupType:
szTitle = "";
szMsg = "";
nResult = SetupType(szTitle, szMsg, "", nSetupType, 0);
if (nResult = BACK) then
goto Dlg_SdCustomerInformation;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
nvSize = 0;
FeatureCompareSizeRequired(MEDIA, INSTALLDIR, nvSize);
if (nvSize != 0) then
MessageBox(szSdStr_NotEnoughSpace, WARNING);
goto Dlg_SetupType;
endif;
bCustom = FALSE;
goto Dlg_SQL;
else
bCustom = TRUE;
endif;
endif;
Dlg_SdAskDestPath:
nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
if (nResult = BACK) goto Dlg_SetupType;
Dlg_SdFeatureTree:
szTitle = "";
szMsg = "";
if (nSetupType = CUSTOM) then
nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2);
if (nResult = BACK) goto Dlg_SdAskDestPath;
endif;
Dlg_SQL:
nResult = OnSQLLogin( nResult );
if( nResult = BACK ) then
if (!bCustom) then
goto Dlg_SetupType;
else
goto Dlg_SdFeatureTree;
endif;
endif;
Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(svName) to a list(listStartCopy).
//eg. ListAddString(listStartCopy,svName,AFTER);
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);
if (nResult = BACK) then
goto Dlg_SQL;
endif;
// setup default status
Enable(STATUSEX);
return 0;
end;
//---------------------------------------------------------------------------
// OnSQLLogin
//---------------------------------------------------------------------------
function number OnSQLLogin( nBtn )
string sMessage;
string szConnection, szServer, szUser, szPassword, szDB, sTemp[MAX_PATH];
number nResult, nSize, nCount;
BOOL bWinLogin, bNext;
LIST listConnections;
begin
//First initialize SQL Server runtime
SQLRTInitialize2();
// Suppress ISSQLSRV.DLL to show a connection error message.
MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_CA_SILENT", "1" );
//Get the names of all the necessary connections
listConnections = SQLRTGetConnections();
ListGetFirstString (listConnections, szConnection);
nCount = 0;
//determine if NEXT or BACK will be returned
//if there are no connections to make
if( nBtn != BACK ) then
bNext = TRUE;
else
bNext = FALSE;
//start at end if going BACK
while (ISERR_SUCCESS = ListGetNextString( listConnections, szConnection ) );
nCount++;
endwhile;
endif;
// Login for each connection
while (nResult = ISERR_SUCCESS)
//Get Default values for connection
SQLRTGetConnectionInfo( szConnection, szServer, szDB, szUser, szPassword );
bWinLogin = SQLRTGetConnectionAuthentication( szConnection );
// Display login dialog (without connection name)
// COMMENT OUT TO SWAP DIALOGS
nResult = SQLServerSelectLogin2( szConnection, szServer, szUser, szPassword, bWinLogin, szDB, FALSE, TRUE );
// Display login dialog (with connection name)
// UNCOMMENT TO SWAP DIALOGS
// nResult = SQLServerSelectLogin2( szConnection, szServer, szUser, szPassword, bWinLogin, szDB, TRUE, TRUE );
if( nResult = NEXT ) then
//store data in case we need it again
SQLRTPutConnectionInfo2( szConnection, szServer, szDB, szUser, szPassword );
SQLRTPutConnectionAuthentication( szConnection, bWinLogin );
//test connection
nResult = SQLRTTestConnection2( szConnection, szServer, szDB, szUser, szPassword, bWinLogin );
nSize = MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_STATUS", sTemp, nSize );
if( sTemp != "0" ) then
nSize = _MAX_PATH;
MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_STATUS_ERROR", sMessage, nSize );
if( nSize = 0 ) then
Sprintf(sMessage, SdLoadString( IDS_IFX_SQL_ERROR_LOGIN_FAILED ), szConnection, SdLoadString( ISCRIPT_E_UNKNOWN_ERROR_DESC ));
endif;
MessageBox( sMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
else //SUCCESS
//Move on to next connection
nCount++;
bNext = TRUE;
nResult = ListGetNextString(listConnections, szConnection);
endif;
else
//BACK
nCount--;
bNext = FALSE;
nResult = ListSetIndex( listConnections, nCount );
ListCurrentString( listConnections, szConnection );
endif;
endwhile;
if( bNext ) then
return NEXT;
else
return BACK;
endif;
end;
[/CODE]
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)