How It Works

Get the list of DSNs from the Registry

The application examines your Registry to build a list of ODBC DSNs. These are found in two locations: System DSNs (available to all users of the computer) each have a subkey in HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI. User DSNs (specific to your user account) each have a subkey in HKEY_CURRENT_USER\Software\ODBC\ODBC.INI.. This is achieved using the System.Management.Registry objects.

Once the list has been created, a user can choose a DSN to export from a list box.

User selects a DSN to export

Upon clicking Export, the application determines which DSN has been chosen and which Registry hive it is found in.

Check for mapped network drives

The application then checks for the presence of mapped network drives using System.Management.ManagementObject to query the Win32_Logical_Disk service for DriveType 4, i.e. mapped network drives.

Get the data for the selected DSN from the Registry

The application then begins exporting the DSN entries from the Registry, both the DSN-specific subkey and the corresponding value in the ODBC Data Sources subkey. If any mapped drives were found in the exported values, it will ask the user if they want to replace any file paths that use them with the associated UNC path, again using System.Management.ManagementObject to query the Win32_Logical_Disk service for the ProviderName, i.e. the UNC path.

Save the file

The user is then prompted for a location to save the .reg file.

Once the file has been saved, the user is informed that export is complete. They can now either export another DSN or exit the application.

Last edited Aug 11, 2011 at 2:29 PM by DaveHelps, version 4

Comments

No comments yet.