반응형

Bursh Name

 

 

출처 : http://cocosoft.kr/68

CString OutlookManager::GetContactCategoryForVer2003()
{
	CString tempCategory = _T("");
	//if(_ContactCategory.IsEmpty())
	//{
		//Get Data, Reg.Category Data to CString
		HKEY hKey;
		LONG lResult = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Office\\11.0\\Outlook\\Categories", 0, KEY_READ, &hKey);
		if (lResult == ERROR_SUCCESS)
		{
			DWORD buf_size = 0;
			if (RegQueryValueEx(hKey, L"MasterList", NULL, NULL, NULL, &buf_size) == ERROR_SUCCESS){ 

				TCHAR *pBuf = new TCHAR[buf_size + 1];

				if(RegQueryValueEx(hKey, L"MasterList", NULL, NULL, (LPBYTE)pBuf, &buf_size) == ERROR_SUCCESS)
				{
					pBuf[buf_size] = _T('\0');
					tempCategory = CString(pBuf);					
				}
				delete[] pBuf;
				pBuf = NULL;
			}
		}
		RegCloseKey(hKey);

		return _ContactCategory = tempCategory;
	//}else{
	//	return _ContactCategory;
	//}
}

void OutlookManager::SetContactCategoryForVer2003(CString value)
{
	//Get Data, Reg.Category Data to CString
	HKEY hKey;
	LONG lResult = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Office\\11.0\\Outlook\\Categories", 0, KEY_WRITE, &hKey);
	if (lResult == ERROR_SUCCESS)
	{	
		//Set
		TCHAR *pBuf = NULL;
		pBuf = (TCHAR*)(LPCTSTR)value;
		DWORD size = (_tcslen(pBuf) + 1) * 2;
		lResult = RegSetValueEx(hKey, L"MasterList", 0, REG_BINARY, (LPBYTE)pBuf, size);
	}
	
	
	CString test = GetContactCategoryForVer2003();			

	RegCloseKey(hKey);
}

반응형
Posted by Rainfly
l