Организация удаленного доступа к распределенным базам данных. Содержание Введение 3 Основные подходы к проектированию распределенных баз данных 5
Скачать 0.97 Mb.
|
Приложение 4Исходные тексты программы установки коммуникационного сервиса #include #include void RegEventSource(); VOID _CRTAPI1 main(void) { LPCTSTR lpszBinaryPathName = TEXT("c:\\ibserver\\bin\\CommServ.exe"); SC_HANDLE schSCManager; SC_HANDLE schService; /* Open a handle to the SC Manager database. */ schSCManager = OpenSCManager( NULL, /* local machine */ NULL, /* ServicesActive database */ SC_MANAGER_ALL_ACCESS); /* full access rights */ if (schSCManager == NULL) { printf("\nError opening Service Manager.\n"); return; } schService = CreateService( schSCManager, /* SCManager database */ TEXT("CommServ"), /* name of service */ TEXT("JSC \"SvjazInform\" Communication Service"), /* service name to display */ SERVICE_ALL_ACCESS, /* desired access */ SERVICE_WIN32_OWN_PROCESS, /* service type */ SERVICE_DEMAND_START, /* start type */ SERVICE_ERROR_NORMAL, /* error control type */ lpszBinaryPathName, /* service's binary */ NULL, /* no load ordering group */ NULL, /* no tag identifier */ NULL, /* no dependencies */ NULL, /* LocalSystem account */ NULL); /* no password */ if (schService == NULL) { printf("\nFailed to create service!\n"); } else printf("CreateService SUCCESS\n"); CloseServiceHandle(schService); CloseServiceHandle(schSCManager); RegEventSource(); } void RegEventSource() { HKEY hk; DWORD dwData; UCHAR szBuf[80]; if (RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\ \\EventLog\\Application\\CommServ", &hk)) { printf("could not create registry key"); return; } /* Set the Event ID message-file name. */ strcpy(szBuf, "c:\\ibserver\\bin\\CommServ.exe"); /* Add the Event ID message-file name to the subkey. */ if (RegSetValueEx(hk, /* subkey handle */ "EventMessageFile", /* value name */ 0, /* must be zero */ REG_EXPAND_SZ, /* value type */ (LPBYTE) szBuf, /* address of value data */ strlen(szBuf) + 1)) /* length of value data*/ { printf("could not set event message file"); return; } /* Set the supported types flags. */ dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; if (RegSetValueEx(hk, /* subkey handle */ "TypesSupported", /* value name */ 0, /* must be zero */ REG_DWORD, /* value type */ (LPBYTE) &dwData, /* address of value data*/ sizeof(DWORD))) /* length of value data */ { printf("could not set supported types"); return; } RegCloseKey(hk); } Приложение 5Исходные тексты программы удаления коммуникационного сервиса #include #include void CleanRegistry(); VOID _CRTAPI1 main(void) { SC_HANDLE schSCManager; SC_HANDLE schService; /* Open a handle to the SC Manager database. */ schSCManager = OpenSCManager( NULL, /* local machine */ NULL, /* ServicesActive database */ SC_MANAGER_ALL_ACCESS); /* full access rights */ if (schSCManager == NULL) { printf("\nError opening Service Manager.\n"); return; } schService = OpenService( schSCManager, /* SCManager database */ TEXT("CommServ"), /* name of service */ DELETE); /* only need DELETE access */ if (! DeleteService(schService) ) printf("\nFailed to Delete service!\n"); else printf("DeleteService SUCCESS\n"); CloseServiceHandle(schService); CloseServiceHandle(schSCManager); } void CleanRegistry() { if (RegDeleteKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\ \\EventLog\\Application\\CommServ")) { printf("\nError Cleaning Registry"); } else { printf("\nCleaning Registry SUCCESS"); } return; } Приложение 6Структуры баз данных |