Menu
Simba Technologies
Simba Technologies

SimbaEngine X SDK Version 10.1.2

Developing Drivers for Data Stores Without SQL

SimbaEngine X SDK Documentation > Productizing Your Driver > Using INI Files for Driver Configuration on Windows

Using INI Files for Driver Configuration on Windows

On Windows platforms, ODBC drivers normally retrieve configuration information from the Windows registry. As an alternative, your driver can retrieve its driver-specific configuration information from an .ini file. This enables customers to deploy multiple versions of the DLL, each with a different version of the driver-specific configuration information. You can also specify that your driver to look for the .ini file initially, then fall back to the registry if the file cannot be found.

You can use a configuration file, for example simba.quickstart.ini, to specify the information that is normally retrieved from the SOFTWARE\Simba\Quickstart\Driver registry key.

Note:

  • The registry key and the file name can be rebranded with your own company and driver name, but this example uses simba and Quickstart for simplicity.
  • This feature does not include using .ini files for information that is stored in the \ODBC\ODBC.INI and \ODBC\ODBCINST registry keys. You still need to configure these registry keys for your custom driver.

Step 1 - Create the simba.quickstart.ini file

Create a text file that contains all the information in the driver's HKEY_LOCAL_MACHINE\SOFTWARE\Simba\Quickstart\Driver registry key. The file has the same format as the simba.quickstart.ini file on Linux and Unix platforms.

Example - simba.quickstart.ini file

[Driver]

ErrorMessagesPath=C:\Drivers\Quickstart\Maintenance\10.1\Product\ErrorMessages

UnicodeDataPath=C:\Drivers\Quickstart\Maintenance\10.1\Product\Setup

DriverLocale=en-US

DriverManagerEncoding=UTF-16

LogLevel=3

LogNamespace=

LogPath=C:\SimbaLogs

Step 2 - Update Simba::DSI::DSIDriverFactory()

In the Simba::DSI::DSIDriverFactory() method in the Main_Windows.cpp file, replace the call to SetConfigurationBranding() with SetConfigurationRegistryKey(), SetConfigurationIniFile(), and SetModuleId(). These methods must be called before any parameter from the SimbaSettingReader is accessed, because the configuration is loaded only once, and cannot be reloaded.

You also need to provide the module ID, using the value provided to the DLLMain() function that is called when the driver is loaded.

Example - DSIDriverFactory

//==============================

/// @brief Creates an instance of IDriver for a driver.

/// The resulting object is made available through DSIDriverSingleton::GetDSIDriver().

/// @param out_instanceID Unique identifier for the IDriver instance.

/// @return IDriver instance. (OWN)

//==============================

IDriver* Simba::DSI::DSIDriverFactory(simba_handle& out_instanceID)

{

out_instanceID = s_quickstartModuleId;

 

//Set the name of the INI file from which to load the driver-specific configuration.

// If a file name is specified here, the SEN SDK will first try to load the driver specific

// configuration from that INI file. If it can't find the file, it will fall

// back to the registry, as described below.

// You can specify a relative path for the file name. If the module ID (see below) is

// 0, then the path is relative to the current working directory. If the module

// ID is non-zero, the path is relative to the

// directory where the DLL is located.

 

#if defined(SERVERTARGET)

SimbaSettingReader::SetConfigurationIniFile(“simbaserver.quickstart.ini”);

#else

SimbaSettingReader::SetConfigurationIniFile(“simba.quickstart.ini”);

#endif

 

// Set the module identifier provided in DLLMain().

//This allows the SDK to determine in which

// directory the driver DLL is located, which is used to load INI file defined

// as relative path as described above.

 

SimbaSettingReader::SetModuleId(s_quickstartModuleId);

 

// Use this setting to specify the registry key that is used if the

// driver cannot find the .ini file.

// For example, if you use the value "Simba\Quickstart", then

// the driver looks for the configuration information at

// HKLM\SOFTWARE\Simba\Quickstart, or

// HKLM\SOFTWARE\SOFTWARE\Wow6432Node\Simba\Quickstart if

// running a 32-bit driver on 64-bit Windows).

// If the DSII is compiled as a driver, then it will use \Driver as the final

// value in the registry path.

// If the DSII is compiled as a server, then it will use \Server as the final

// value in the registry path.

// For example, a 64-bit driver would use

// HKLM\SOFTWARE\Simba\Quickstart\Driver to look up the registry keys such as ErrorMessagesPath.

 

SimbaSettingReader::SetConfigurationRegistryKey(“Simba\\Quickstart”);

 

// Set the server branding for this data source. This will only be used if the DSII is compiled

// as a server and then installed as a service.

#if defined(SERVERTARGET) && defined(WIN32)

SimbaSettingReader::SetServiceName("SimbaQuickstartService");

#endif

 

return new QSDriver();

}