/*++ Copyright (c) 1996 Microsoft Corporation Module Name: registry.c Abstract: This file provides access to the registry. Environment: WIN32 User Mode Author: Wesley Witt (wesw) 17-Feb-1996 --*/ #include "wizard.h" #pragma hdrstop BOOL CreateDeviceProvider( HKEY hKey, LPTSTR ProviderKey, LPTSTR FriendlyName, LPTSTR ImageName, LPTSTR ProviderName ) { hKey = OpenRegistryKey( hKey, ProviderKey, TRUE, KEY_ALL_ACCESS ); if (!hKey) { DebugPrint(( TEXT("could not create/open registry key (test)") )); return FALSE; } if (!SetRegistryString( hKey, REGVAL_FRIENDLY_NAME, FriendlyName )) { DebugPrint(( TEXT("could not add friendly name value") )); return FALSE; } if (!SetRegistryStringExpand( hKey, REGVAL_IMAGE_NAME, ImageName )) { DebugPrint(( TEXT("could not add image name value") )); return FALSE; } if (!SetRegistryString( hKey, REGVAL_PROVIDER_NAME, ProviderName )) { DebugPrint(( TEXT("could not add provider name value") )); return FALSE; } RegCloseKey( hKey ); return TRUE; } BOOL CreateRoutingMethod( HKEY hKey, LPTSTR MethodName, LPTSTR FunctionName, LPTSTR FriendlyName, LPTSTR Guid ) { hKey = OpenRegistryKey( hKey, MethodName, TRUE, KEY_ALL_ACCESS ); if (!hKey) { DebugPrint(( TEXT("could not create/open registry key for routing method") )); return FALSE; } if (!SetRegistryString( hKey, REGVAL_FUNCTION_NAME, FunctionName )) { DebugPrint(( TEXT("could not add function name value") )); return FALSE; } if (!SetRegistryString( hKey, REGVAL_FRIENDLY_NAME, FriendlyName )) { DebugPrint(( TEXT("could not add friendly name value") )); return FALSE; } if (!SetRegistryString( hKey, REGVAL_GUID, Guid )) { DebugPrint(( TEXT("could not add function name value") )); return FALSE; } RegCloseKey( hKey ); return TRUE; } BOOL CreateMicrosoftRoutingExtension( HKEY hKey, LPTSTR RoutingKey, LPTSTR FriendlyName, LPTSTR ImageName ) { HKEY hKeyMethods; hKey = OpenRegistryKey( hKey, RoutingKey, TRUE, KEY_ALL_ACCESS ); if (!hKey) { Assert(( ! TEXT("could not create/open registry key for routing extension") )); return FALSE; } if (!SetRegistryString( hKey, REGVAL_FRIENDLY_NAME, FriendlyName )) { Assert(( ! TEXT("could not add friendly name value") )); return FALSE; } if (!SetRegistryStringExpand( hKey, REGVAL_IMAGE_NAME, ImageName )) { Assert(( ! TEXT("could not add image name value") )); return FALSE; } hKeyMethods = OpenRegistryKey( hKey, REGKEY_ROUTING_METHODS, TRUE, KEY_ALL_ACCESS ); if (!hKeyMethods) { Assert(( ! TEXT("could not create/open registry key for routing methods") )); return FALSE; } CreateRoutingMethod( hKeyMethods, REGKEY_ROUTING_METHOD_EMAIL, REGVAL_RM_EMAIL_FUNCTION, REGVAL_RM_EMAIL_FRIENDLY, REGVAL_RM_EMAIL_GUID ); CreateRoutingMethod( hKeyMethods, REGKEY_ROUTING_METHOD_FOLDER, REGVAL_RM_FOLDER_FUNCTION, REGVAL_RM_FOLDER_FRIENDLY, REGVAL_RM_FOLDER_GUID ); CreateRoutingMethod( hKeyMethods, REGKEY_ROUTING_METHOD_INBOX, REGVAL_RM_INBOX_FUNCTION, REGVAL_RM_INBOX_FRIENDLY, REGVAL_RM_INBOX_GUID ); CreateRoutingMethod( hKeyMethods, REGKEY_ROUTING_METHOD_PRINTING, REGVAL_RM_PRINTING_FUNCTION, REGVAL_RM_PRINTING_FRIENDLY, REGVAL_RM_PRINTING_GUID ); RegCloseKey( hKeyMethods ); RegCloseKey( hKey ); return TRUE; } VOID RegCreateFaxDevice( HKEY hKeyDev, DWORD PermanentLineID, DWORD Rings, DWORD Priority, DWORD Flags, LPTSTR DeviceName, LPTSTR ProviderName, LPTSTR Csid, LPTSTR Tsid, DWORD RoutingMask, LPTSTR RoutePrinterName, LPTSTR RouteDir, LPTSTR RouteProfile ) { HKEY hKey; HKEY hKeyRouting; TCHAR PortName[32]; _stprintf( PortName, TEXT("%08d"), PermanentLineID ); hKey = OpenRegistryKey( hKeyDev, PortName, TRUE, KEY_ALL_ACCESS ); if (!hKey) { Assert(( ! TEXT("Could not open device registry key") )); return; } if (!SetRegistryDword( hKey, REGVAL_PERMANENT_LINEID, PermanentLineID )) { Assert(( ! TEXT("Could not set device id registry value") )); } if (!SetRegistryDword( hKey, REGVAL_FLAGS, Flags )) { Assert(( ! TEXT("Could not set device flags registry value") )); } if (!SetRegistryDword( hKey, REGVAL_RINGS, Rings )) { Assert(( ! TEXT("Could not set device rings registry value") )); } if (!SetRegistryDword( hKey, REGVAL_PRIORITY, Priority )) { Assert(( ! TEXT("Could not set device rings registry value") )); } if (!SetRegistryString( hKey, REGVAL_DEVICE_NAME, DeviceName )) { Assert(( ! TEXT("Could not set device name registry value") )); } if (!SetRegistryString( hKey, REGVAL_PROVIDER, ProviderName )) { Assert(( ! TEXT("Could not set provider name registry value") )); } if (!SetRegistryString( hKey, REGVAL_ROUTING_CSID, Csid )) { Assert(( ! TEXT("Could not set csid registry value") )); } if (!SetRegistryString( hKey, REGVAL_ROUTING_TSID, Tsid )) { Assert(( ! TEXT("Could not set csid registry value") )); } hKeyRouting = OpenRegistryKey( hKey, REGKEY_ROUTING, TRUE, KEY_ALL_ACCESS ); if (!hKeyRouting) { Assert(( ! TEXT("Could not open routing registry key") )); return; } if (!SetRegistryString( hKeyRouting, REGVAL_ROUTING_PRINTER, RoutePrinterName )) { Assert(( ! TEXT("Could not set printer name registry value") )); } if (!SetRegistryString( hKeyRouting, REGVAL_ROUTING_DIR, RouteDir )) { Assert(( ! TEXT("Could not set routing dir registry value") )); } if (!SetRegistryString( hKeyRouting, REGVAL_ROUTING_PROFILE, RouteProfile )) { Assert(( ! TEXT("Could not set routing profile name registry value") )); } if (!SetRegistryDword( hKeyRouting, REGVAL_ROUTING_MASK, RoutingMask )) { Assert(( ! TEXT("Could not set routing mask registry value") )); } RegCloseKey( hKeyRouting ); RegCloseKey( hKey ); } BOOL SetServerRegistryData( VOID ) { HKEY hKey; LONG rVal; DWORD i; HKEY hKeyDev; HANDLE hNull; STARTUPINFO si; PROCESS_INFORMATION pi; TCHAR CmdLine[128]; DWORD RoutingMask; LPTSTR LodCmdLine; // // set top level defaults // hKey = OpenRegistryKey( HKEY_LOCAL_MACHINE, REGKEY_SOFTWARE, TRUE, KEY_ALL_ACCESS ); if (!hKey) { Assert(( ! TEXT("Could not open software registry key") )); return FALSE; } if (InstallMode & INSTALL_NEW) { if (!SetRegistryDword( hKey, REGVAL_RETRIES, DEFAULT_REGVAL_RETRIES )) { Assert(( ! TEXT("Could not set retries registry value") )); } if (!SetRegistryDword( hKey, REGVAL_RETRYDELAY, DEFAULT_REGVAL_RETRYDELAY )) { Assert(( ! TEXT("Could not set retry delay registry value") )); } if (!SetRegistryDword( hKey, REGVAL_DIRTYDAYS, DEFAULT_REGVAL_DIRTYDAYS )) { Assert(( ! TEXT("Could not set dirty days registry value") )); } if (!SetRegistryDword( hKey, REGVAL_QUEUE_PAUSED, DEFAULT_REGVAL_QUEUE_PAUSED )) { Assert(( ! TEXT("Could not set queue paused registry value") )); } if (!SetRegistryDword( hKey, REGVAL_JOB_NUMBER, DEFAULT_REGVAL_JOB_NUMBER )) { Assert(( ! TEXT("Could not net job number registry value") )); } if (!SetRegistryDword( hKey, REGVAL_BRANDING, DEFAULT_REGVAL_BRANDING )) { Assert(( ! TEXT("Could not set branding registry value") )); } if (!SetRegistryDword( hKey, REGVAL_USE_DEVICE_TSID, DEFAULT_REGVAL_USEDEVICETSID )) { Assert(( ! TEXT("Could not set usedevicetsid registry value") )); } if (!SetRegistryString( hKey, REGVAL_INBOUND_PROFILE, EMPTY_STRING )) { Assert(( ! TEXT("Could not set inbound profile registry value") )); } if (!SetRegistryDword( hKey, REGVAL_SERVERCP, DEFAULT_REGVAL_SERVERCP )) { Assert(( ! TEXT("Could not set servercp registry value") )); } if (!SetRegistryDword( hKey, REGVAL_STARTCHEAP, DEFAULT_REGVAL_STARTCHEAP )) { Assert(( ! TEXT("Could not set startcheap registry value") )); } if (!SetRegistryDword( hKey, REGVAL_STOPCHEAP, DEFAULT_REGVAL_STOPCHEAP )) { Assert(( ! TEXT("Could not set stopcheap registry value") )); } if (!SetRegistryDword( hKey, REGVAL_ARCHIVEFLAG, DEFAULT_REGVAL_ARCHIVEFLAG )) { Assert(( ! TEXT("Could not set archiveflag registry value") )); } if (!SetRegistryString( hKey, REGVAL_ARCHIVEDIR, DEFAULT_REGVAL_ARCHIVEDIR )) { Assert(( ! TEXT("Could not set archive dir registry value") )); } RegCloseKey( hKey ); } if (InstallMode & INSTALL_NEW) { hKeyDev = OpenRegistryKey( HKEY_LOCAL_MACHINE, REGKEY_FAX_DEVICES, TRUE, KEY_ALL_ACCESS ); if (!hKey) { Assert(( ! TEXT("Could not open devices registry key") )); return FALSE; } // // set the routing mask // RoutingMask = 0; if (WizData.RoutePrint) { RoutingMask |= LR_PRINT; } if (WizData.RouteStore) { RoutingMask |= LR_STORE; } if (WizData.RouteMail) { RoutingMask |= LR_INBOX; } if (WizData.UseDefaultPrinter || WizData.RoutePrinterName[0]) { RoutingMask |= LR_PRINT; } // // enumerate the devices and create the registry data // for (i=0; i