Exemple #1
1
BOOL CCpDialog::OnInitDialog()
{
	CString strAppRootFolder = GetHomeFolder() + String(GetFolderId());

	CString strContentRootFolder;
	CRegKey regkey;
	if (regkey.Open(HKEY_CURRENT_USER, REGKEY_APP) == ERROR_SUCCESS)
	{
		ULONG nLen = 255;
		char* pszValue = new char[nLen+1];

		*pszValue = 0;
		nLen = 256;
		if (regkey.QueryStringValue(REGVAL_CONTENT_FOLDER, pszValue, &nLen) == ERROR_SUCCESS)
		{
			pszValue[nLen] = 0;
			strContentRootFolder = CString(pszValue);
		}

		delete [] pszValue;
	}

	if (strContentRootFolder.IsEmpty())
		strContentRootFolder = GetHomeFolder() + String(IDS_CONTENT_FOLDER);

	DWORD dwCount = CheckForUiUpdates(strAppRootFolder);
	CheckForNewContent(strContentRootFolder, strAppRootFolder, (dwCount > 0)/*bForceCreate*/);

	// Update the variables.xsl and linelist.xml files
	SaveAppVariablesFile(strContentRootFolder, strAppRootFolder);
	SaveContentVariablesFile(strContentRootFolder, strAppRootFolder);

	CString strCaption;
	strCaption.LoadString(GetTitleId());
	SetWindowText(strCaption);

	// Initialize the url prior to calling CDHtmlDialog::OnInitDialog()
	if (m_strCurrentUrl.IsEmpty())
		m_strCurrentUrl = "about:blank";

	CDHtmlDialog::OnInitDialog();

	// This magically makes the scroll bars appear and dis-allows text selection
	DWORD dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_THEME | DOCHOSTUIFLAG_DIALOG; // DOCHOSTUIFLAG_NO3DOUTERBORDER;
	SetHostFlags(dwFlags);

	// Add "About..." menu item to system menu.
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(false);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icons for this dialog
	SetIcon(m_hIcon, true);		// Set big icon
	SetIcon(m_hIcon, false);	// Set small icon

	// Set the window size and position
	CRect rect;
	rect.SetRect(0, 0, 800, 600);
	if (0) // Restore the saved window size and position
	{
		DWORD dwSize = sizeof(rect);
		regkey.QueryBinaryValue(REGVAL_LOCATION, &rect, &dwSize);

		//j Someday, clip the rect to the display
		SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
	}
	else
	{
		SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
		CenterWindow();
	}

	CString strHomePage = strAppRootFolder + String(IDS_HOME_PAGE);
	if (FileExists(strHomePage))
		Navigate(strHomePage);

	ShowWindow(SW_NORMAL);

	DragAcceptFiles(false);

	return true;  // return TRUE  unless you set the focus to a control
}
Exemple #2
0
/////////////////////////////////////////////////////////////////////////////
// Set the IE registry settings that control caching
// Never check for new content unless it doesn't exist in the cache
void CSmartCache::SetSyncMode()
{
	CRegKey regkey;
	if (regkey.Open(HKEY_CURRENT_USER, REGKEY_IE) != ERROR_SUCCESS)
		return;	

	DWORD dwOldSyncMode = SYNCMODE_AUTO;
	DWORD dwOldSyncMode5 = SYNCMODE_AUTO;

	DWORD dwLength = sizeof(DWORD);
	regkey.QueryBinaryValue(REGVAL_SYNCMODE, &dwOldSyncMode, &dwLength);
	regkey.QueryDWORDValue(REGVAL_SYNCMODE5, dwOldSyncMode5);

	if (dwOldSyncMode == SYNCMODE_NEVER && dwOldSyncMode5 == SYNCMODE_NEVER)
		return;

	DWORD dwNever = SYNCMODE_NEVER;
	dwLength = sizeof(DWORD);
	regkey.SetBinaryValue(REGVAL_SYNCMODE, &dwNever, dwLength);
	regkey.SetDWORDValue(REGVAL_SYNCMODE5, dwNever);

	if (m_dwOldSyncMode == -1)
		m_dwOldSyncMode = (dwOldSyncMode != SYNCMODE_NEVER ? dwOldSyncMode : SYNCMODE_AUTO);

	if (m_dwOldSyncMode5 == -1)
		m_dwOldSyncMode5 = (dwOldSyncMode5 != SYNCMODE_NEVER ? dwOldSyncMode5 : SYNCMODE_AUTO);
}
bool CRegProfile::GetProfileBinary (LPCTSTR lpszSection, LPCTSTR lpszEntry, LPBYTE pData, UINT uBytes, BOOL bGlobal)
{
	LONG r;
	ULONG sz = uBytes;
	CRegKey key;
	r = key.Open(bGlobal?HKEY_LOCAL_MACHINE:HKEY_CURRENT_USER,m_sPath+lpszSection);
	if(r!=ERROR_SUCCESS) return FALSE;
	r = key.QueryBinaryValue(lpszEntry,pData,&sz);
	key.Close();
	if(r!=ERROR_SUCCESS) return FALSE;
	return TRUE;
}
Exemple #4
0
// Get the alternative colors for compressed and encrypted files/folders. This function uses either the value defined in the Explorer configuration or the default color values.
_Success_( return != clrDefault ) COLORREF CDirstatApp::GetAlternativeColor( _In_ COLORREF clrDefault, _In_z_  PCTSTR which ) {
	COLORREF x;
	DWORD cbValue = sizeof( x );
	CRegKey key;

	// Open the explorer key
	key.Open( HKEY_CURRENT_USER, _T( "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" ), KEY_READ );

	// Try to read the REG_BINARY value
	if ( ERROR_SUCCESS == key.QueryBinaryValue( which, &x, &cbValue ) ) {
		return x;
		}
	return clrDefault;
	}
// Get the alternative colors for compressed and encrypted files/folders.
// This function uses either the value defined in the Explorer configuration
// or the default color values.
COLORREF CDirstatApp::GetAlternativeColor(COLORREF clrDefault, LPCTSTR which)
{
	const LPCTSTR explorerKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
	COLORREF x; DWORD cbValue = sizeof(x); CRegKey key;

	// Open the explorer key
	key.Open(HKEY_CURRENT_USER, explorerKey, KEY_READ);

	// Try to read the REG_BINARY value
	if (ERROR_SUCCESS == key.QueryBinaryValue(which, &x, &cbValue))
	{
		// Return the read value upon success
		return x;
	}
	else
	{
		// Return the default upon failure
		return clrDefault;
	}
}
Exemple #6
0
BOOL COther::GetMsnReceiveDir( CAtlArray<CString>& ReceiveDirArray )
{

    HKEY hKey = NULL;
    CString SubKeyPath = L"Software\\Microsoft\\MSNMessenger";

    CAtlArray<HKEY> OtherUserCurReg;
    HRESULT hr = COtherUserCurReg::GetOtherUsrCurReg( OtherUserCurReg );
    if ( FAILED(hr) )
    {
        return FALSE;
    }

    size_t Num = OtherUserCurReg.GetCount();
    size_t i = 0;
    for (; i<Num; ++i )
    {
        hKey = OtherUserCurReg[i];

        CRegKey MsnMainKey;
        LONG Result = ERROR_SUCCESS;
        Result = MsnMainKey.Open( hKey, SubKeyPath, KEY_READ );
        if ( ERROR_SUCCESS != Result )
        {
            continue;
        }

        WCHAR TmpMsnReceivePath[MAX_PATH+1] ={0};
        DWORD BufByteNum = (MAX_PATH+1)*sizeof(TCHAR);
        Result = MsnMainKey.QueryBinaryValue( L"FtReceiveFolder", TmpMsnReceivePath, &BufByteNum );
        TmpMsnReceivePath[MAX_PATH] = NULL;
        if ( ERROR_SUCCESS == Result )
        {
            BOOL bAdd = TRUE;
            size_t NumRv = ReceiveDirArray.GetCount();
            size_t j = 0;
            for (; j<NumRv; ++j )
            {
                if ( 0 == ReceiveDirArray[j].CompareNoCase(TmpMsnReceivePath) )
                {
                    bAdd = FALSE;
                    break;
                }
            }
            if ( bAdd )
            {
                ReceiveDirArray.Add( TmpMsnReceivePath );
            }
        }
    }
    
    size_t nNum = OtherUserCurReg.GetCount();
    size_t Index = 0;
    for(; Index<nNum; ++Index )
    {
        ::RegCloseKey( OtherUserCurReg[Index] );
    }

    if ( ReceiveDirArray.IsEmpty() )
    {
        return FALSE;
    }
    return TRUE;
}