Lecture 12
Windows registry Structure of the registry Loading and storing data in registry
Structure of the registry Tree with the following roots: –HKEY_CLASSES_ROOT –HKEY_CURRENT_CONFIG –HKEY_CURRENT_USER –HKEY_LOCAL_MACHINE –HKEY_USERS
Structure of the registry Registry structure Data is stored in tree-like structure Nodes of the tree are called "Keys" Key can have any number of sub-keys and any number of values For example:...\YourApplicationKey "WindowPosition" = "10x20x300x350" "DefaultDirectory" = "C:\My Documents"
Structure of the registry Some registry keys are used by the system, for example: HKLM\Software\Microsoft\Windows\ \CurrentVersion\Run - contains applications that will be executed at windows startup Other keys are used by applications to store their settings
HKEY_CLASSES_ROOT Stores: –file extension - program association –information about COM objects class identifiers ({ AA006D2EA4}) program identifiers (Word.Document.8)
HKEY_LOCAL_MACHINE Global computer settings (common to all users) Applications usually store their settings in "Software" subkey, typically: HKLM\Software\Company Name\ \Application Name\Version
Registry functions (keys) Keys –RegCreateKeyEx() - create key and open –RegOpenKeyEx() - open existing key –RegCloseKey() - close key –RegDeleteKey() - delete registry key –RegEnumKeyEx - enumerate sub keys –RegQueryInfoEx() - get information about the key
Registry functions (values) RegSetValueEx() - set key value RegQueryValueEx(), RegQueryMultipleValues() - get key value RegDeleteValue() - delete key value RegEnumValue() - enumerate key values
Shell functions FindExecutable – find executable for document file ShellExecute – run application and open document file, run Windows Explorer WinHelp – display help for the application
File drag and drop DragAcceptFiles – inform Windows that application window accepts dropped files WM_DROPFILES – message sent after file(s) has been dropped on application window DragQueryFile – retrieve the name of the file that was dropped DragQueryPoint – retrieve the point where the file(s) have been dropped
Windows Tray Application that wants to minimize the window to tray should: –Create Windows Tray icon (using Shell_NotifyIcon function) –Hide main application window Application that only wants to display icon in the tray should: –Create hidden window (that window will process messages from the icon) –Create Windows Tray icon (using Shell_NotifyIcon function) In order to display windows tray icon, an application must be running
Clipboard Copying data to clipboard: –call OpenClipboard() –call EmptyClipboard() –call SetClipboardData() and pass handle to memory allocated with GlobalAlloc() –call CloseClipboard()
Clipboard Pasting data from clipboard –call OpenClipboard() –check data format: IsClipboardFormatAvailable(), EnumClipboardFormats(), GetPriorityClipboardFormat(), CountClipboardFormats() –call GetClipboardData() –call CloseClipboard()