Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

14 System functions


'This tutorial covers the Windows Registry and Environment variables

'Registry -VB can access registry information at:
'HKEY_CURRENT_USER\Software\VB and VBA Program Settings\appname\section\key\value

'A registry entry includes a reference to the program, a section, a key, and a value.  Windows supports
values of String , Binary, Or DWORD Type , but VB only supports String key values. VB Registry functions are:

GetSetting   'gets a value from a section\key
SaveSetting   'saves a value in the registry for a section\key
DeleteSetting  'deletes a section or key
GetAllSettings  'returns all key/values pairs from an application\setting of the Registry

'The Registry is a database of most Windows settings, as well as those for your installed applications.

'In Windows 95, 98, and Me, the Registry is contained in two hidden files in your
'Windows directory, called USER.DAT and SYSTEM.DAT.

'In Windows 2000 and Windows XP, the Registry is stored in several Hives (special files), located
'in the \windows\system32\config and \Documents and Settings\{username} folders.

'Windows 2000 and WIndows XP have five main branches:
'- HKEY_CLASSES_ROOT - contains all of file types as well as OLE information for OLE-aware applications.
'- HKEY_CURRENT_USER - points to the part of HKEY_USERS appropriate for the current user.
'- HKEY_LOCAL_MACHINE - information about all of the hardware and software installed on your
'- HKEY_USERS - preferences (such as colors and control panel settings) for each of the users of the computer.
'- HKEY_CURRENT_CONFIG - the part of HKEY_LOCAL_MACHINE appropriate for the current hardware configuration.

'Registry Editor
'Windows includes a program called the Registry Editor (regedit.exe) which allows
'you to view and edit the contents of the Registry.  

'Registry Patch
'A Registry patch is a simple text file with the .REG extension that contains one or more keys
'or values. If you double-click on a .REG file, the patch is applied to the registry.   You can
'create a Registry patch by opening the Registry Editor, selecting a branch, and choosing
'Export from the File menu.

============================================================================

'Environment variables
MyString = Environ( "PATH" 'returns the Windows Path spec

'Environment variables are strings that contain information such as
'drive, path, or file name. They control the behavior of various programs.
'For example, the TEMP environment variable specifies the location in
'which programs place temporary files.   The PATH environment variable
'determines the path(s) where Windows will look for executable files.