long PASCAL GetRegMultiStringValue ( register LPCTSTR lpszSubKey, register LPCTSTR lpszKey, register LPTSTR lpString) { HKEY hKey ; DWORD dwRegType, dwData, dwDataSize, dwRet ; TCHAR szRegInfoPath [MAX_PATH] ; dwData = 0 ; /* */ lstrcpy (szRegInfoPath, g_szRegInfoPath) ; if (lpszSubKey) lstrcat (szRegInfoPath, lpszSubKey) ; MyDebugPrint((TEXT("Getting: %s: path=%s\n"), lpszKey, szRegInfoPath)); if (RegOpenKeyEx (HKEY_CURRENT_USER, szRegInfoPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS && RegOpenKeyEx (HKEY_LOCAL_MACHINE, szRegInfoPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) return -1 ; dwRet = RegQueryValueEx (hKey, lpszKey, NULL, &dwRegType, (LPBYTE)lpString, &dwDataSize) ; RegCloseKey (hKey) ; if (dwRet != ERROR_SUCCESS || dwRegType != REG_MULTI_SZ) return -1 ; MyDebugPrint((TEXT("OK %s\n"), lpszKey)); return (long)dwDataSize ; }
BOOL GetRegKeyHandle(LPCTSTR lpszSubKey, HKEY *hKey) { TCHAR szRegInfoPath [MAX_PATH] ; lstrcpy (szRegInfoPath, g_szRegInfoPath) ; if (lpszSubKey) lstrcat (szRegInfoPath, lpszSubKey) ; if (RegOpenKeyEx (HKEY_CURRENT_USER, szRegInfoPath, 0, KEY_READ, hKey) != ERROR_SUCCESS && RegOpenKeyEx (HKEY_LOCAL_MACHINE, szRegInfoPath, 0, KEY_READ, hKey) != ERROR_SUCCESS) { MyDebugPrint((TEXT(">>FAIL: path=%s\n"), szRegInfoPath)); return FALSE; } MyDebugPrint((TEXT(">>OK: path=%s\n"), szRegInfoPath)); return TRUE; }
//******************************************************************** void ErrCloseFile(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrCloseFile"); gwLowRC_rout = IDS_ERR_CLOSE_FILE; }
//******************************************************************** void ErrPossibleLossOfData(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrPossibleLossOfData"); gwLowRC_rout = IDS_ERR_POSSIBLE_LOSS_OF_DATA; }
//******************************************************************** void ErrPictureData(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrPictureData"); gwLowRC_rout = IDS_ERR_PICTURE_DATA; }
//******************************************************************** void ErrPageNotLoaded(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrPageNotLoaded"); gwLowRC_rout = IDS_ERR_PAGE_NOT_LOADED; }
//******************************************************************** void ErrObjectNotFound(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrObjectNotFound"); gwLowRC_rout = IDS_ERR_OBJECT_NOT_FOUND; }
//******************************************************************** void ErrUpdateActiveAlphabet(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrUpdateActiveAlphabet"); gwLowRC_rout = IDS_ERR_UPDATE_ACTIVE_ALPHABET; }
//******************************************************************** void ErrLoadRec6List(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrLoadRec6List"); gwLowRC_rout = IDS_ERR_LOAD_REC6LIST; }
//******************************************************************** void ErrOpenFile(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrOpenFile"); gwLowRC_rout = IDS_ERR_OPEN_FILE; }
//******************************************************************** void ErrWritingToFile(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrWritingToFile"); gwLowRC_rout = IDS_ERR_WRITING_TO_FILE; }
//******************************************************************** void NoMemory(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("NoMemory"); gwLowRC_rout = IDS_ERR_NO_MEMORY; }
//******************************************************************** void WrongArgument(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("WrongArgument"); gwLowRC_rout = IDS_ERR_WRONG_ARGUMENT; }
//******************************************************************** void NotImplemented(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("NotImplemented"); gwLowRC_rout = IDS_ERR_NOTIMPLEMENT; }
//******************************************************************** void ErrLoadAlphabet(const char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrLoadAlphabet"); gwLowRC_rout = IDS_ERR_LOAD_ALPHABET; }
//******************************************************************** void ErrCreateDirectory(char *file, long line) { gFile = file; gLine = line; MyDebugPrint("ErrCreateDirectory"); gwLowRC_rout = IDS_ERR_CREATE_DIRECTORY; }
//******************************************************************** Bool PictureFromChar(Handle charHandle) { /* Прочесть описание кортинки из спецсимвола Записывает: gPictureNumber - Номер картинки от 1 gPictureData - Адрес DIB включая заголовок gPictureLength - Длина DIB включая заголовок */ gPictureData = 0; gPictureLength = 0; memset (&gPictureSize,0,sizeof(gPictureSize)); memset (&gPictureGoal,0,sizeof(gPictureGoal)); gPictureNumber = GetPictureNumber(charHandle); long pictUserNumber=0, pictAlign=0, type=0; long picturesCount = CED_GetNumOfPics(gPageHandle); for ( long index = 0; index < picturesCount; index++ ) { if( CED_GetPicture( gPageHandle, index, (int*)&pictUserNumber, // Пользовательский номер &gPictureSize, // Размер картинки в TIFF-файле в пикселах &gPictureGoal, // Размер картинки на экране в twips (int*)&pictAlign, // Вертикальное расположение (int*)&type, // Тип = 1 (DIB) (void**)&gPictureData, // Адрес DIB включая заголовок (int*)&gPictureLength // Длина DIB включая заголовок ) && pictUserNumber == gPictureNumber ) { if (!gPictureData || gPictureLength < 0 ) { ERR_PICTURE_DATA; MyDebugPrint("pictUserNumber = %d",pictUserNumber); goto Fail; } return TRUE; } } // ASSERT(gPictureData); // ASSERT(gPictureLength >= 0); Fail: gPictureData = 0; gPictureLength = 0; memset (&gPictureSize,0,sizeof(gPictureSize)); memset (&gPictureGoal,0,sizeof(gPictureGoal)); gPictureNumber = -1; return FALSE; }
void SetDwordToSetting(LPCTSTR lpszFlag, DWORD dwFlag) { HKEY hkey; DWORD dwDataSize, dwRet; if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, g_szRegInfoPath, 0, KEY_WRITE, &hkey)) { dwRet = RegSetValueEx(hkey, lpszFlag, 0, REG_DWORD, (CONST BYTE *) &dwFlag, sizeof(DWORD)); RegCloseKey(hkey); } MyDebugPrint((TEXT("Setting: %s=%#8.8x: dwRet=%#8.8x\n"), lpszFlag, dwFlag, dwRet)); }
DWORD PASCAL GetDwordFromSetting(LPTSTR lpszFlag) { HKEY hkey; DWORD dwRegType, dwData, dwDataSize, dwRet; dwData = 0; dwDataSize=sizeof(DWORD); if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, g_szRegInfoPath, 0, KEY_READ, &hkey)) { dwRet = RegQueryValueEx(hkey, lpszFlag, NULL, &dwRegType, (LPBYTE)&dwData, &dwDataSize); RegCloseKey(hkey); } MyDebugPrint((TEXT("Getting: %s=%#8.8x: dwRet=%#8.8x\n"), lpszFlag, dwData, dwRet)); return dwData; }
void GetRegKeyList(LPCTSTR lpszSubKey) { HKEY hKey ; TCHAR szRegInfoPath [MAX_PATH] ; lstrcpy (szRegInfoPath, g_szRegInfoPath) ; if (lpszSubKey) lstrcat (szRegInfoPath, lpszSubKey) ; MyDebugPrint((TEXT("Getting: path=%s\n"), szRegInfoPath)); if (RegOpenKeyEx (HKEY_CURRENT_USER, szRegInfoPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS && RegOpenKeyEx (HKEY_LOCAL_MACHINE, szRegInfoPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) return; { /* from MSDN document */ #define MAX_KEY_LENGTH 260 #define MAX_VALUE_NAME 16383 WCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name DWORD cbName; // size of name string CHAR achClass[MAX_PATH] = ""; // buffer for class name DWORD cchClassName = MAX_PATH; // size of class string DWORD cSubKeys=0; // number of subkeys DWORD cbMaxSubKey; // longest subkey size DWORD cchMaxClass; // longest class string DWORD cValues; // number of values for key DWORD cchMaxValue; // longest value name DWORD cbMaxValueData; // longest value data DWORD cbSecurityDescriptor; // size of security descriptor FILETIME ftLastWriteTime; // last write time DWORD i, retCode; WCHAR achValue[MAX_VALUE_NAME]; DWORD cchValue = MAX_VALUE_NAME; // Get the class name and the value count. retCode = RegQueryInfoKey( hKey, // key handle (LPWSTR)achClass, // buffer for class name &cchClassName, // size of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time #if 0 // Enumerate the subkeys, until RegEnumKeyEx fails. if (cSubKeys) { MyDebugPrint((TEXT("Number of subkeys: %d\n"), cSubKeys)); for (i=0; i<cSubKeys; i++) { cbName = MAX_KEY_LENGTH; retCode = RegEnumKeyEx(hKey, i, achKey, &cbName, NULL, NULL, NULL, &ftLastWriteTime); if (retCode == ERROR_SUCCESS) { MyDebugPrint((TEXT("(%d) %s\n"), i+1, achKey)); } } } #endif // Enumerate the key values. if (cValues) { MyDebugPrint((TEXT("\nNumber of values: %d\n"), cValues)); for (i=0, retCode=ERROR_SUCCESS; i<cValues; i++) { cchValue = MAX_VALUE_NAME; achValue[0] = '\0'; retCode = RegEnumValue(hKey, i, achValue, &cchValue, NULL, NULL, NULL, NULL); if (retCode == ERROR_SUCCESS ) { MyDebugPrint((TEXT("(%d) %s\n"), i+1, achValue)); } } } } }