Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 36 of file dcatalog.c.
Referenced by WsTcInitializeFromRegistry().
{ INT ErrorCode; DWORD CreateDisposition; HKEY CatalogKey, NewKey; //DWORD CatalogEntries = 0; DWORD RegType = REG_DWORD; DWORD RegSize = sizeof(DWORD); DWORD UniqueId = 0; DWORD NewData = 0; /* Initialize the catalog lock and namespace list */ InitializeCriticalSection((LPCRITICAL_SECTION)&Catalog->Lock); InitializeListHead(&Catalog->ProtocolList); /* Open the Catalog Key */ ErrorCode = RegOpenKeyEx(ParentKey, TCCATALOG_NAME, 0, MAXIMUM_ALLOWED, &CatalogKey); /* If we didn't find the key, create it */ if (ErrorCode == ERROR_SUCCESS) { /* Fake that we opened an existing key */ CreateDisposition = REG_OPENED_EXISTING_KEY; } else if (ErrorCode == ERROR_FILE_NOT_FOUND) { /* Create the Catalog Name */ ErrorCode = RegCreateKeyEx(ParentKey, TCCATALOG_NAME, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &CatalogKey, &CreateDisposition); } /* Fail if that didn't work */ if (ErrorCode != ERROR_SUCCESS) return FALSE; /* Check if we had to create the key */ if (CreateDisposition == REG_CREATED_NEW_KEY) { /* Write the count of entries (0 now) */ ErrorCode = RegSetValueEx(CatalogKey, "Num_Catalog_Entries", 0, REG_DWORD, (LPBYTE)&NewData, sizeof(NewData)); if (ErrorCode != ERROR_SUCCESS) { /* Close the key and fail */ RegCloseKey(CatalogKey); return FALSE; } /* Write the first catalog entry ID */ NewData = 1001; ErrorCode = RegSetValueEx(CatalogKey, "Next_Catalog_Entry_ID", 0, REG_DWORD, (LPBYTE)&NewData, sizeof(NewData)); if (ErrorCode != ERROR_SUCCESS) { /* Close the key and fail */ RegCloseKey(CatalogKey); return FALSE; } /* Write the first catalog entry Uniqe ID */ NewData = 1; ErrorCode = RegSetValueEx(CatalogKey, "Serial_Access_Num", 0, REG_DWORD, (LPBYTE)&NewData, sizeof(NewData)); if (ErrorCode != ERROR_SUCCESS) { /* Close the key and fail */ RegCloseKey(CatalogKey); return FALSE; } /* Create a key for this entry */ ErrorCode = RegCreateKeyEx(CatalogKey, "Catalog_Entries", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &NewKey, &CreateDisposition); if (ErrorCode != ERROR_SUCCESS) { /* Close the key and fail */ RegCloseKey(CatalogKey); return FALSE; } /* Close the key since we don't need it */ RegCloseKey(NewKey); } else { /* Read the serial number */ ErrorCode = RegQueryValueEx(CatalogKey, "Serial_Access_Num", 0, &RegType, (LPBYTE)&UniqueId, &RegSize); /* Check if it's missing for some reason */ if (ErrorCode != ERROR_SUCCESS) { /* Write the first catalog entry Unique ID */ NewData = 1; ErrorCode = RegSetValueEx(CatalogKey, "Serial_Access_Num", 0, REG_DWORD, (LPBYTE)&NewData, sizeof(NewData)); } } /* Set the Catalog Key */ Catalog->CatalogKey = CatalogKey; return TRUE; }