Example #1
0
BOOL MonitorStatus()
{
	CRegKey hkey;
	if(hkey.Open(HKEY_CURRENT_USER, _T("Software\\easyMule"), KEY_READ) != ERROR_SUCCESS)
		return TRUE;

	DWORD dwMonitor;
	if(hkey.QueryDWORDValue(_T("Monitor"), dwMonitor) != ERROR_SUCCESS)
		return TRUE;

	BOOL bALT = GetKeyState (VK_MENU) & 0x8000;
	BOOL bCTRL = GetKeyState (VK_CONTROL) & 0x8000;

	if (bCTRL)
		return FALSE;

	DWORD bALTShouldPressed = FALSE;
	if(hkey.QueryDWORDValue(_T("MonitorOnAlt"), bALTShouldPressed) != ERROR_SUCCESS)
		return dwMonitor;

	if (bALT == FALSE && bALTShouldPressed)
		return FALSE; 

	return dwMonitor;
}
Example #2
0
void SourceEdit::LoadSettings(CRegKey& key)
{
  DWORD value;
  if (key.QueryDWORDValue("Source Tab Size Chars",value) == ERROR_SUCCESS)
  {
    if (value > 0)
      CallEdit(SCI_SETTABWIDTH,value);
  }

  if (key.QueryDWORDValue("Auto Indent",value) == ERROR_SUCCESS)
    m_autoIndent = (value != 0);

  // Adjust elastic tabstops
  bool elastic = true;
  if (key.QueryDWORDValue("Auto Space Tables",value) == ERROR_SUCCESS)
    elastic = (value != 0);
  SetElasticTabStops(elastic);

  // Adjust wrapped line indentation
  bool indent = true;
  if (key.QueryDWORDValue("Indent Wrapped Lines",value) == ERROR_SUCCESS)
    indent = (value != 0);
  if (indent)
  {
    int indent = (int)((CallEdit(SCI_GETTABWIDTH) / 3.0) + 0.5);
    CallEdit(SCI_SETWRAPSTARTINDENT,indent);
    CallEdit(SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_INDENT);
  }
  else
  {
    CallEdit(SCI_SETWRAPSTARTINDENT,0);
    CallEdit(SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_FIXED);
  }
}
Example #3
0
HRESULT ObjectMemory::InitializeZct()
{
	CRegKey rkDump;
	ZctReserve = ZCTRESERVE;
	ZctMinSize = ZCTINITIALSIZE;
	if (OpenDolphinKey(rkDump, "ObjMem", KEY_READ)==ERROR_SUCCESS)
	{
		DWORD dwValue;
		if (rkDump.QueryDWORDValue("ZMax", dwValue) == ERROR_SUCCESS && dwValue > ZCTMINRESERVE)
			ZctReserve = dwValue;
		if (rkDump.QueryDWORDValue("ZMin", ZctMinSize) == ERROR_SUCCESS && dwValue > ZCTMINSIZE &&
				dwValue < ZctReserve)
			ZctMinSize = dwValue;
	}

	//trace("ZctMinSize = %u, ZctReserve = %u\n", ZctMinSize, ZctReserve);
	m_nZctEntries = 0;
	m_bIsReconcilingZct = false;
	m_pZct = static_cast<OTE**>(::VirtualAlloc(NULL, ZctReserve*sizeof(OTE*), MEM_RESERVE, PAGE_NOACCESS));
	if (!m_pZct)
		return ReportError(IDP_ZCTRESERVEFAIL, ZctReserve, 0);

	m_nZctHighWater = ZctMinSize >> 1;
	GrowZct();

#ifdef _DEBUG
	dwLastReconcileTicks = timeGetTime();
#endif

	return S_OK;
}
Example #4
0
LRESULT CPreviewWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
  CRegKey key;

  key.Open(HKEY_CURRENT_USER, lpcstrTG2RegKey, KEY_READ);
  DWORD tiled = 0, zoom = 4, alpha = 1;
  key.QueryDWORDValue(_T("TextureTiled"), tiled);
  key.QueryDWORDValue(_T("TextureZoom"), zoom);
	key.QueryDWORDValue(_T("TextureAlpha"), alpha);
  key.Close();
  
  m_client.Create(m_hWnd, rcDefault, 0, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN, 0);

  CFontHandle fnt = AtlGetDefaultGuiFont();

  m_tile.Create(m_hWnd, CRect(2, 0, 36, 20), _T("tile"), WS_CHILD|WS_VISIBLE|FRBS_AUTO3D_SINGLE|FRBS_CHECK|FRBS_HOTTRACK|FRBS_SOLID|FRBS_AUTO, 0, 100);
  m_tile.SetFont(fnt);
  m_tile.SetCheck(tiled);
  m_tile.SetColorScheme(RGB(0, 0, 0), RGB(0, 0, 255), RGB(66, 65, 64), RGB(103, 99, 96),
    RGB(174, 169, 167), RGB(174, 169, 167), RGB(200, 198, 196));
  m_client.SetTiled(tiled);

	if (zoom == 2)
		zoom++; // 1:3 is out

  m_zoom.Create(m_hWnd, CRect(40, 0, 100, 20), 0, WS_CHILD|WS_VISIBLE|FRBS_FLAT|FRBS_HOTTRACK, 0, 101);
  m_zoom.AddMenuItem(1, "1:4");
  m_zoom.AddMenuItem(3, "1:2");
  m_zoom.AddMenuItem(4, "1:1");
  m_zoom.AddMenuItem(5, "2:1");
  m_zoom.AddMenuItem(6, "3:1");
  m_zoom.AddMenuItem(7, "4:1");
  m_zoom.SetSelection(zoom);
  m_zoom.SetFont(fnt);
  m_zoom.SetColorScheme(RGB(0, 0, 0), RGB(0, 0, 255), RGB(66, 65, 64), RGB(103, 99, 96),
    RGB(174, 169, 167), RGB(174, 169, 167), RGB(200, 198, 196));

	m_alpha.Create(m_hWnd, CRect(104, 0, 174, 20), 0, WS_CHILD|WS_VISIBLE|FRBS_FLAT|FRBS_HOTTRACK, 0, 102);
	m_alpha.AddMenuItem(1, "no alpha");
	m_alpha.AddMenuItem(2, "photoshop");
	m_alpha.SetSelection(alpha);
	m_alpha.SetFont(fnt);
	m_alpha.SetColorScheme(RGB(0, 0, 0), RGB(0, 0, 255), RGB(66, 65, 64), RGB(103, 99, 96),
		RGB(174, 169, 167), RGB(174, 169, 167), RGB(200, 198, 196));
	m_client.SetAlphaMode(alpha - 1);
  
  static const sInt s1tab[] = { 1, 1, 1, 1, 2, 3, 4 };
  static const sInt s2tab[] = { 4, 3, 2, 1, 1, 1, 1 };
  m_client.SetScale(s1tab[zoom - 1], s2tab[zoom - 1]);
  
  CMessageLoop* pLoop = _Module.GetMessageLoop();
  pLoop->AddMessageFilter(this);

  m_bgBrush.CreateSolidBrush(RGB(174, 169, 167));
  
  bHandled = FALSE;
  return 0;
}
Example #5
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);
}
Example #6
0
 ///process based init
 /// todo - destructor order(I am not sure if it is correct!!)
 bool PluginMng::InitPlugins(){
   if (plugins_.empty()){
     LoadPlugins();
     uuiterator vb=plugins_.begin(),ve=plugins_.end();
     for (uuiterator i=vb;i!=ve;++i){
       uuplugin* p= *i;
       CRegKey crk;
       long rk=crk.Open(HKEY_LOCAL_MACHINE, _6bees_const::kplugindisabled, KEY_READ|KEY_WRITE);
       if (rk==ERROR_SUCCESS){
         DWORD i=0;
         ATL::CString menuid;
         menuid.Format(_T("%d"),p->menuwID_);
         if (crk.QueryDWORDValue(menuid,i)==ERROR_SUCCESS){
           p->enabled_ = false;
         }
       }
       if (p->enabled_){
         p->init();
       }else{
         disabled_plugins_.push_back(p);
       }
     }
     fillpartswidth();
   }
   return true;
 }
Example #7
0
/*-----------------------------------------------------------------------------
	Check to see if we're supposed to be doing activity-based measurement
-----------------------------------------------------------------------------*/
DWORD CPagetestBase::CheckABM(void)
{
	EnterCriticalSection(&cs);
	
	abm = -1;
	if( runningScript )
		abm = script_ABM;
	
	if( abm == -1 )
	{
		// check the abm flag and if it is set, use that as the end of document measurement
		// this should be removed when the analysts can use the activity time field instead
		abm = 1;
		CRegKey key;
		if( key.Open(HKEY_CURRENT_USER, _T("Software\\America Online\\SOM"), KEY_READ) == ERROR_SUCCESS )
		{
			key.QueryDWORDValue(_T("ABM"), abm);
			key.Close();
		}
	}

	LeaveCriticalSection(&cs);
	
	return abm;
}
Example #8
0
void CDataCeneter::GetDDNSInfo(BYTE bOperation, LPVOID VarData)
{
	struDDNS *pDDNSData = (struDDNS*)VarData;
	
	ULONG ulChars = 1024;
	CRegKey regKey;
	if( regKey.Open(HKEY_LOCAL_MACHINE, GetRegFolder()) == ERROR_SUCCESS)
	{
		regKey.QueryDWORDValue(_T("EnableDDNS"), (DWORD&)pDDNSData->bEnableDDNS);
		regKey.QueryDWORDValue(_T("Provider"), (DWORD&)pDDNSData->Provider);
		regKey.QueryStringValue(_T("ProviderURL"), pDDNSData->szProviderURL,&ulChars);
		regKey.QueryStringValue(_T("DDNSUser"), pDDNSData->szUser,&ulChars);
		regKey.QueryStringValue(_T("DDNSPass"), pDDNSData->szPass,&ulChars);
		regKey.QueryDWORDValue(_T("IntervalTime"), (DWORD&)pDDNSData->nIntervalTime);
	}
	regKey.Close();
}
bool IsVC2010()
{
    CRegKey key;
    if (key.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\VisualStudio\\10.0\\VC\\VCRedist\\x86", KEY_QUERY_VALUE) != ERROR_SUCCESS)
        return false;

    DWORD installed = 0;
    return (key.QueryDWORDValue("Installed", installed) == ERROR_SUCCESS && installed != 0);
}
Example #10
0
void CMyAddin::LoadToolbarSettings() {
	CRegKey regKey;
	DWORD top, left, visible, position, rowIndex;

	if (regKey.Open(HKEY_CURRENT_USER, APP_REG_KEY)!=0) {
		m_pToolBar->PutVisible(VARIANT_TRUE);
		return;
	}

	if (regKey.QueryDWORDValue("Top", top)!=0) {
		m_pToolBar->PutVisible(VARIANT_TRUE);
		goto end;
	}

	if (regKey.QueryDWORDValue("Left", left)!=0) {
		m_pToolBar->PutVisible(VARIANT_TRUE);
		goto end;
	}

	if (regKey.QueryDWORDValue("Visible", visible)!=0) {
		m_pToolBar->PutVisible(VARIANT_TRUE);
		goto end;
	}

	if (regKey.QueryDWORDValue("Position", position)!=0) {
		m_pToolBar->PutVisible(VARIANT_TRUE);
		goto end;
	}

	if (regKey.QueryDWORDValue("RowIndex", rowIndex)!=0) {
		m_pToolBar->PutVisible(VARIANT_TRUE);
		goto end;
	}

	m_pToolBar->Position = (Office::MsoBarPosition)position;
	m_pToolBar->RowIndex = (int)rowIndex;
	m_pToolBar->Top = (int)top;
	m_pToolBar->Left = (int)left;
	m_pToolBar->Visible = (visible!=0)?VARIANT_TRUE:VARIANT_FALSE;

end:

	regKey.Close();	
}
Example #11
0
bool CMediaFormats::IsExtHidden()
{
    CRegKey key;
    if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), KEY_READ)) {
        DWORD value;
        if (ERROR_SUCCESS == key.QueryDWORDValue(_T("HideFileExt"), value)) {
            return !!value;
        }
    }
    return false;
}
Example #12
0
HRESULT CExeModule::LoadProviderSettings()
{
	m_dwBatchNotificationDelay = 1000;
	m_bEnableRegionals         = true; 
	CRegKey key;
	HRESULT hr = S_OK;
	_bstr_t bsKey = PROVIDER_SETTINGS_ROOT;
	DWORD dwRes = key.Open(HKEY_LOCAL_MACHINE, bsKey, KEY_READ);
	if (dwRes == ERROR_SUCCESS)
	{
		DWORD dw = 0;
		if(ERROR_SUCCESS == key.QueryDWORDValue("BatchNotificationDelay", dw))
			m_dwBatchNotificationDelay = dw;

		dw = 0;
		if(ERROR_SUCCESS == key.QueryDWORDValue("DisableRegionals", dw))
			m_bEnableRegionals = (dw==0);
	}
	return hr;
}
Example #13
0
bool RegKeyValueExists(LPCTSTR pKeyName, LPCTSTR pValueName)
{
	CRegKey regkey;
	if (regkey.Open(HKEY_CURRENT_USER, pKeyName) != ERROR_SUCCESS)
		return false;

	DWORD dwValue = 0;
	if (regkey.QueryDWORDValue(pValueName, dwValue) != ERROR_SUCCESS)
		return false;
		
	return true;
}
/**
* Once registered, this is a simple way to retrieve our 
* event framework cookie.
*/
HRESULT RetrieveRegistrationCookie(long* cookie) {
  ATLASSERT(cookie != NULL);
  CRegKey key;
  LONG res = key.Open(HKEY_CURRENT_USER, CONSOLE_CONFIG_KEY, KEY_READ);
  if (res != ERROR_SUCCESS)
    return AtlHresultFromWin32(res);

  res = key.QueryDWORDValue(COOKIE_VALUE,
                            *reinterpret_cast<DWORD*>(cookie));
  ATLASSERT(res == ERROR_SUCCESS);
  return AtlHresultFromWin32(res);
}
int CRegProfile::GetProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault, BOOL bGlobal)
{
	LONG r;
	DWORD val;
	CRegKey key;
	r = key.Open(bGlobal?HKEY_LOCAL_MACHINE:HKEY_CURRENT_USER,m_sPath+lpszSection);
	if(r!=ERROR_SUCCESS) return nDefault;
	r = key.QueryDWORDValue(lpszEntry,val);
	key.Close();
	if(r==ERROR_SUCCESS) return (int)val;
	return nDefault;
}
Example #16
0
// Static initialization of async call support
void OverlappedCall::Initialize()
{
	HARDASSERT(::GetCurrentThreadId() == Interpreter::MainThreadId());

	CRegKey rkOverlap;
	if (OpenDolphinKey(rkOverlap, L"Overlapped")==ERROR_SUCCESS)
	{
		rkOverlap.QueryDWORDValue(L"TerminateTimeout", s_dwTerminateTimeout);
		s_dwTerminateTimeout = max(s_dwTerminateTimeout, 100);
	}
	else
	{
		s_dwTerminateTimeout = 500;
	}
}
Example #17
0
bool CCpDialog::CheckForNewContent(CString& strContentRootFolder, CString& strAppRootFolder, bool bForceCreate)
{
	if (strContentRootFolder.IsEmpty())
		return false;

	CString strLinelistPage = strAppRootFolder + String(IDS_LINELIST_PAGE);
	bool bLinelistExists = FileExists(strLinelistPage);

	// Check the registry for the last saved file count, if the linelist file exists
	DWORD dwOldFileCount = 0;
	CRegKey regkey;
	if (regkey.Open(HKEY_CURRENT_USER, REGKEY_APP) == ERROR_SUCCESS)
	{
		if (bLinelistExists && !bForceCreate)
			regkey.QueryDWORDValue(REGVAL_FILECOUNT, dwOldFileCount);
	}

	CXmlFileSystem xml;
	xml.SetFileSpec("*.*");
	CString strLinelistFolder = strContentRootFolder + String(IDS_LINELIST_FOLDER);
	DWORD dwFileCount = xml.FileSystemCount(strLinelistFolder);
	if (dwFileCount == dwOldFileCount)
		return false;

	if (!xml.CreateXml(strLinelistFolder))
		return false;

	if (bLinelistExists)
	{
		DWORD dwFileAttributes = ::GetFileAttributes(strLinelistPage);
		if (dwFileAttributes && FILE_ATTRIBUTE_READONLY)
			::SetFileAttributes(strLinelistPage, dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
	}

	if (!xml.Save(strLinelistPage))
		return false;

	// Write the file count out to the registry so we can detect changes in the future
	if (regkey.m_hKey != NULL)
		regkey.SetDWORDValue(REGVAL_FILECOUNT, dwFileCount);

	#ifdef _DEBUG
	if (dwOldFileCount)
		MessageBox("New content has been installed on your machine.  It has been imported automatically.", String(GetTitleId()), MB_OK);
	#endif _DEBUG

	return true;
}
Example #18
0
bool DotNetChecker::IsCheckSatisfied()
{
	return true;

	bool res = false;
	CRegKey reg;
	if ( reg.Open( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full")) == ERROR_SUCCESS )
	{
		DWORD dwInstallValue = 0;
		if ( reg.QueryDWORDValue( _T("Install") , dwInstallValue ) == ERROR_SUCCESS )
		{
			if ( dwInstallValue == 1 )
				res = true;
		}
	}
	return res;
}
Example #19
0
short CDepSettings::GetIISMajorVer()
{
	if (m_nIISMajorVer != -1)
		return m_nIISMajorVer;

	CRegKey verKey;
	if (ERROR_SUCCESS == verKey.Open(HKEY_LOCAL_MACHINE,
						_T("SOFTWARE\\Microsoft\\INetStp"),
						KEY_READ))
	{
		DWORD dwValue = 0xFFFFFFFF;
		if (ERROR_SUCCESS == verKey.QueryDWORDValue(_T("MajorVersion"), dwValue))
		{
			m_nIISMajorVer = (short)dwValue;
		}
	}
	return m_nIISMajorVer;
}
Example #20
0
    proxy_settings proxy_settings_manager::load_from_registry()
    {
        proxy_settings settings;

        settings.use_proxy_ = false;
        CRegKey key;
        if (key.Open(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings") == ERROR_SUCCESS)
        {
            DWORD proxy_used = 0;
            if (key.QueryDWORDValue(L"ProxyEnable", proxy_used) == ERROR_SUCCESS)
            {
                if (proxy_used == 0)
                    return settings;

                wchar_t buffer[MAX_PATH];
                unsigned long len = MAX_PATH;
                if (key.QueryStringValue(L"ProxyServer", buffer, &len) == ERROR_SUCCESS)
                {
                    settings.proxy_server_ = std::wstring(buffer);
                    if (settings.proxy_server_.empty())
                        return settings;

                    settings.use_proxy_ = true;
                    settings.proxy_type_ = CURLPROXY_HTTP;

                    if (key.QueryStringValue(L"ProxyUser", buffer, &len) == ERROR_SUCCESS)
                    {
                        settings.login_ = std::wstring(buffer);
                        if (settings.login_.empty())
                            return settings;

                        settings.need_auth_ = true;

                        if (key.QueryStringValue(L"ProxyPass", buffer, &len) == ERROR_SUCCESS)
                        {
                            settings.password_ = std::wstring(buffer);
                        }
                    }
                }
            }
        }

        return settings;
    }
Example #21
0
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
	CMyMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	CMainFrame wndMain;
  RECT rc=CWindow::rcDefault;
  CRegKey key;
  
  DWORD nShow=nCmdShow;
  sChar winpos[128];
  sU32 winsz=128;

  key.Open(HKEY_CURRENT_USER, lpcstrTG2RegKey, KEY_READ);
  key.QueryDWORDValue(_T("WindowMode"), nShow);
  key.QueryStringValue(_T("WindowPos"), winpos, &winsz);

  sscanf(winpos, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom);

  if (rc.left>=GetSystemMetrics(SM_CXSCREEN) || rc.top>=GetSystemMetrics(SM_CYSCREEN) ||
    rc.right<=rc.left || rc.bottom<=rc.top) // sanity checks
    rc=CWindow::rcDefault;

  key.Close();

	if(wndMain.CreateEx(0, rc) == NULL)
	{
		ATLTRACE(_T("Main window creation failed!\n"));
		return 0;
	}

  mbHWnd = wndMain.m_hWnd;
  ruleMouseInit(mbHWnd);

	wndMain.ShowWindow(nShow);
	int nRet = theLoop.Run();
	_Module.RemoveMessageLoop();

  ruleMouseClose();
  mbHWnd = 0;

	return nRet;
}
Example #22
0
DWORD WINAPI _threadInitialize (LPVOID)
{
	#ifdef LOG_WEBFILES_TREE
		log_webfiles_init ();
	#endif

	DWORD dwOverrideUEF = FALSE;
	try {
		CRegKey key;
		if (ERROR_SUCCESS == key.Open (HKEY_CURRENT_USER, _T ("Software\\FreeDownloadManager.ORG\\Free Download Manager\\Debug"), KEY_READ))
			key.QueryDWORDValue (_T ("FlvSniffOverrideUEF"), dwOverrideUEF);
	}
	catch (...) {}
	if (dwOverrideUEF)
		SetUnhandledExceptionFilter (_UEF);

	vmsUrlMonSpyDll::MakeSureDllLoaded ();
	return 0;
}
DWORD OfflineDocIDResolver::GetDWORDValue(const CStdString& sKey, const CStdString& sName ) const
{
    CRegKey reg;
    DWORD dwValue = 0;
    if(reg.Open(HKEY_CURRENT_USER , sKey) != ERROR_SUCCESS)
    {
        CStdString sErr = _T("Failed to Open Key : ") + sKey;
        LOG_WS_ERROR(sErr.c_str());
        return -1;
    }

    if(reg.QueryDWORDValue(sName , dwValue) != ERROR_SUCCESS)
    {
        CStdString sErr = _T("Failed to Read DWord value for key : ")  + sKey;
        LOG_WS_ERROR(sErr.c_str());
        return -1;
    }

    return dwValue;
}
Example #24
0
void CIBALoginDlg::OnCancel()
{
	// 2015-0828 liyajun
	CRegKey regKey;
	LONG lRet = regKey.Open(HKEY_CURRENT_USER, _T("Software\\Sunlike\\IBA"));

	if (ERROR_SUCCESS == lRet)
	{
		DWORD dwValue = 0;
		lRet = regKey.QueryDWORDValue(_T("IsFN"), *(DWORD*)&dwValue);
		if (ERROR_SUCCESS == lRet)
		{
			regKey.DeleteValue(_T("IsFN"));
			regKey.DeleteSubKey(_T("IsFN"));
		}

		regKey.Close();
	}
	CIBADialog::OnCancel();
}
Example #25
0
void CSmartCache::SetRestoreSmartCacheSetting(bool bSave, bool& bUseSmartCache)
{
	CRegKey regkey;
	if (regkey.Create(REGKEY_APPROOT, REGKEY_APP) != ERROR_SUCCESS)
		return;

	DWORD dwValue = bUseSmartCache;
	if (bSave)
	{
		if (regkey.SetDWORDValue(REGVAL_SMARTCACHE, dwValue) == ERROR_SUCCESS)
			return;
	}
	else
	{
		if (regkey.QueryDWORDValue(REGVAL_SMARTCACHE, dwValue) == ERROR_SUCCESS)
			bUseSmartCache = (bool)(dwValue != 0);
	}

	m_bUseSmartCache = bUseSmartCache;
}
Example #26
0
int CSVPNet::SetCURLopt(CURL *curl)
{
	//struct curl_slist *headerlist=NULL;
	//static const char buf[] = "Expect:";
	AppSettings& s = AfxGetAppSettings();

	char buff[MAX_PATH];
	if(s.szOEMTitle.IsEmpty()){
		sprintf_s( buff, "SPlayer Build %d", SVP_REV_NUMBER );
	}else{
		CSVPToolBox svpToolBox;
		int iDescLen = 0;
		char *oem = svpToolBox.CStringToUTF8(s.szOEMTitle, &iDescLen);
		sprintf_s( buff, "SPlayer Build %d OEM%s", SVP_REV_NUMBER ,oem );
		free(oem);
	}
	char buff_cookie[UNIQU_HASH_SIZE];
	memset(buff_cookie,0,UNIQU_HASH_SIZE);
	{
		
		CString path;
		GetModuleFileName(NULL, path.GetBuffer(MAX_PATH), MAX_PATH);
		path.ReleaseBuffer();
		int Ret = -1;
		path.MakeLower();
		//SVP_LogMsg5(L"got splayer path %s" ,path);
		if( path.Find(_T("splayer")) >= 0 || path.Find(_T("svplayer")) >= 0 || path.Find(_T("mplayerc")) >= 0  ){
			DWORD             dwHandle;
			UINT              dwLen;
			UINT              uLen;
			UINT              cbTranslate;
			LPVOID            lpBuffer;

			dwLen  = GetFileVersionInfoSize(path, &dwHandle);

			TCHAR * lpData = (TCHAR*) malloc(dwLen);
			if(lpData){
				
			memset((char*)lpData, 0 , dwLen);


				/* GetFileVersionInfo() requires a char *, but the api doesn't
				* indicate that it will modify it */
				if(GetFileVersionInfo(path, dwHandle, dwLen, lpData) != 0)
				{
					
						CString szParm( _T("\\StringFileInfo\\000004b0\\FileDescription"));

						if(VerQueryValue(lpData, szParm, &lpBuffer, &uLen) != 0)
						{

							CString szProductName((TCHAR*)lpBuffer);
							//SVP_LogMsg3("szProductName %s", szProductName);
							szProductName.MakeLower();

							if(szProductName.Find(_T("射手")) >= 0 || szProductName.Find(_T("splayer")) >= 0  ){
								Ret = 125;
								
							}
						}

				
				}
			}
		}
		if(Ret == 125){
			//sprintf_s(buff_cookie , UNIQU_HASH_SIZE, "UQID=%s", uniqueIDHash);
			//curl_easy_setopt(curl, CURLOPT_COOKIE , buff_cookie);
		}else{
			//sprintf_s(buff_cookie , UNIQU_HASH_SIZE, "UQID=%s", uniqueIDHash);
			
			//curl_easy_setopt(curl, CURLOPT_COOKIE , buff_cookie);
		}
	}
	

	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
	curl_easy_setopt(curl, CURLOPT_USERAGENT, buff);

	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 40);
	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 20);
	curl_easy_setopt(curl,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_0); //must use 1.0 for proxy

	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
	//curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv2);
#if 1
    if(iTryID%2 == 0){
	    DWORD ProxyEnable = 0;
	    CString ProxyServer;
	    DWORD ProxyPort = 0;

	    ULONG len = 256+1;
	    CRegKey key;
	    if( ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), KEY_READ)
		    && ERROR_SUCCESS == key.QueryDWORDValue(_T("ProxyEnable"), ProxyEnable) && ProxyEnable
		    && ERROR_SUCCESS == key.QueryStringValue(_T("ProxyServer"), ProxyServer.GetBufferSetLength(256), &len))
	    {
    		

    	
		    CStringA p_str("http://");
		    p_str.Append(CStringA(ProxyServer));
		    curl_easy_setopt(curl, CURLOPT_PROXY,  p_str.GetBuffer());//
		    p_str.ReleaseBuffer();
		    //curl_easy_setopt(curl, CURLOPT_PROXYPORT, 3128);
		    //p_str.ReleaseBuffer();
		    //curl_easy_setopt(curl,CURLOPT_PROXYTYPE,CURLPROXY_HTTP_1_0);
		    SVP_LogMsg6("Using proxy %s", p_str);
    	
		    //ProxyServer.ReleaseBufferSetLength(len);
	    }else{
		    //curl_easy_setopt(curl,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_NONE);
	    }
    }
#endif

    if(fp_curl_verbose){
	    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
        curl_easy_setopt(curl, CURLOPT_STDERR, fp_curl_verbose);
    }

    //SVP_LogMsg5(L"iTryID %d", iTryID);
	//curl_easy_setopt(curl, CURLOPT_ENCODING, "gzip"); not native supported. so dont use this option
	// MUST not have this line curl_easy_setopt(curl, CURLOPT_POST, ....);
	
	//headerlist = curl_slist_append(headerlist, buf); //WTF ??
	//curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
	return 0;
}
Example #27
0
CMpcAudioRenderer::CMpcAudioRenderer(LPUNKNOWN punk, HRESULT *phr)
    : CBaseRenderer(__uuidof(this), NAME("MPC - Audio Renderer"), punk, phr)
    , m_pDSBuffer		(NULL )
    , m_pSoundTouch		(NULL )
    , m_pDS				(NULL )
    , m_dwDSWriteOff	(0	  )
    , m_nDSBufSize		(0	  )
    , m_dRate			(1.0  )
    , m_pReferenceClock	(NULL )
    , m_pWaveFileFormat	(NULL )
    , pMMDevice			(NULL)
    , pAudioClient		(NULL )
    , pRenderClient		(NULL )
    , m_useWASAPI		(true )
    , m_bMuteFastForward(false)
    , m_csSound_Device	(_T(""))
    , nFramesInBuffer	(0 )
    , hnsPeriod			(0 )
    , hTask				(NULL )
    , bufferSize		(0)
    , isAudioClientStarted (false)
    , lastBufferTime	(0)
    , hnsActualDuration	(0)
    , m_lVolume(DSBVOLUME_MIN)
{
    HMODULE		hLib;

#ifdef REGISTER_FILTER
    CRegKey key;
    TCHAR buff[256];
    ULONG len;

    if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"), KEY_READ)) {
        DWORD dw;
        if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseWasapi"), dw)) {
            m_useWASAPI = !!dw;
        }
        if (ERROR_SUCCESS == key.QueryDWORDValue(_T("MuteFastForward"), dw)) {
            m_bMuteFastForward = !!dw;
        }
        len = sizeof(buff)/sizeof(buff[0]);
        memset(buff, 0, sizeof(buff));
        if (ERROR_SUCCESS == key.QueryStringValue(_T("SoundDevice"), buff, &len)) {
            m_csSound_Device = CString(buff);
        }
    }
#else
    m_useWASAPI = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPC Audio Renderer"), _T("UseWasapi"), m_useWASAPI);
    m_bMuteFastForward = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPC Audio Renderer"), _T("MuteFastForward"), m_bMuteFastForward);
    m_csSound_Device = AfxGetApp()->GetProfileString(_T("Filters\\MPC Audio Renderer"), _T("SoundDevice"), _T(""));
#endif
    m_useWASAPIAfterRestart = m_useWASAPI;


    // Load Vista specifics DLLs
    hLib = LoadLibrary (L"AVRT.dll");
    if (hLib != NULL) {
        pfAvSetMmThreadCharacteristicsW		= (PTR_AvSetMmThreadCharacteristicsW)	GetProcAddress (hLib, "AvSetMmThreadCharacteristicsW");
        pfAvRevertMmThreadCharacteristics	= (PTR_AvRevertMmThreadCharacteristics)	GetProcAddress (hLib, "AvRevertMmThreadCharacteristics");
    } else {
        m_useWASAPI = false;    // Wasapi not available below Vista
    }

    TRACE(_T("CMpcAudioRenderer constructor\n"));
    if (!m_useWASAPI) {
        DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc2, (VOID*)&m_csSound_Device);
        m_pSoundTouch	= new soundtouch::SoundTouch();
        *phr = DirectSoundCreate8 (&lpSoundGUID, &m_pDS, NULL);
    }
}
Example #28
0
bool CIISxpressRegSettings::Load(void)
{
	CComCritSecLock<CComAutoCriticalSection> lock(m_csConfig);

	CRegKey Config;
	if (Config.Open(HKEY_LOCAL_MACHINE, m_sRegPath, KEY_READ | m_dwOpenFlags) != ERROR_SUCCESS)
	{
		return Save();
	}	

	// if we are running as 32bit then see if we need to use the 64bit registry
	if (sizeof(PVOID) == 4 && m_dwOpenFlags == 0)
	{
		DWORD dwUse64BitReg = 0;
		if (Config.QueryDWORDValue(IISXPRESS_REGKEY_USE64BITREG, dwUse64BitReg) == ERROR_SUCCESS && dwUse64BitReg != 0)
		{
			m_dwOpenFlags = KEY_WOW64_64KEY;

			Config.Close();

			return Load();
		}	
	}

	int nFails = 0;

	// get the enabled value
	DWORD dwEnabled = 1;
	if (Config.QueryDWORDValue(IISXPRESS_REGKEY_ENABLED, dwEnabled) != ERROR_SUCCESS)
	{
		nFails++;
	}		

	::InterlockedExchange((LONG*) &m_dwEnabled, dwEnabled);

	// get the logging level
	DWORD dwLoggingLevel = IISXPRESS_LOGGINGLEVEL_NONE;
	if (Config.QueryDWORDValue(IISXPRESS_REGKEY_LOGGINGLEVEL, dwLoggingLevel) != ERROR_SUCCESS)
	{
		nFails++;
	}

	::InterlockedExchange((LONG*) &m_dwLoggingLevel, dwLoggingLevel);

	// get the debug value
	DWORD dwDebugEnabled = 0;
	Config.QueryDWORDValue(IISXPRESS_REGKEY_DEBUGENABLED, dwDebugEnabled);

	::InterlockedExchange((LONG*) &m_dwDebugEnabled, dwDebugEnabled);

	TCHAR installPath[1024] = _T("\0");
	ULONG installPathSize = _countof(installPath);
	if (Config.QueryStringValue(IISXPRESS_REGKEY_INSTALLPATH, installPath, &installPathSize) == ERROR_SUCCESS)
	{
		m_sInstallPath = installPath;
	}
	else
	{
		m_sInstallPath.Empty();
		nFails++;
	}

	if (nFails == 0)
		m_bDirty = false;	

	if (nFails > 0)
		Save();
	
	::InterlockedExchange((LONG*) &m_dwLoadCookie, MakeLoadCookie());

	return true;
}
Example #29
0
BOOL CRemoteSrvPort::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	CRegKey regKey;
    DWORD nHttpPort(8080);
	//TCHAR szRegValue[1024];
	//::ZeroMemory(&szRegValue[0], sizeof(szRegValue));
	const DWORD len = 1024;
	DWORD nActualLen(len);
    CString csForder(CProductDefine::m_tzRegistSubFolder);

	LONG nRet = regKey.Open(HKEY_LOCAL_MACHINE, csForder.GetBuffer());
	if(nRet != ERROR_SUCCESS)
	{
		if( regKey.Create(HKEY_LOCAL_MACHINE, csForder.GetBuffer()) != 0)
		{
			TRACE(_T("Create Registry Fail."));
		}
	}
	
	//nRet = regKey.QueryValue(szRegValue, _T("REMOTESRVPORT"), &nActualLen);
	//if(nRet != ERROR_SUCCESS)
	//{
	//	TRACE(_T("Registry Query Fail!\r\n"));
	//}
	//regKey.Close();
	nRet = regKey.QueryDWORDValue(_T("HTTPPORT"), nHttpPort);
	if(nRet != ERROR_SUCCESS)
	{
        nRet = regKey.SetValue(nHttpPort, _T("HTTPPORT") );
		TRACE(_T("Registry Query Fail!\r\n"));
	}

	regKey.Close();
	BOOL bSaveDef=false;
	if (nHttpPort==0)
	{
		nHttpPort=8080;
		bSaveDef=true;
	}

    CString csHttpPort;
    csHttpPort.Format(_T("%d"), nHttpPort);
	this->SetDlgItemText(IDC_EDIT_SRV_PORT, csHttpPort);
	if (bSaveDef)
	{
		vSetPort2Reg();
	}

	//this->SetDlgItemText(IDC_EDIT_SRV_PORT, szRegValue);

	//::ZeroMemory(&szRegValue[0], sizeof(szRegValue));

	nRet = regKey.Open(HKEY_LOCAL_MACHINE, csForder.GetBuffer());
	if(nRet != ERROR_SUCCESS)
	{
		if( regKey.Create(HKEY_LOCAL_MACHINE, csForder.GetBuffer()) != 0)
		{
			TRACE(_T("Create Registry Fail."));
		}
	}

	DWORD dwRTSPPort;
	CString csRTSPProt;
	nRet = regKey.QueryDWORDValue(_T("RTSPServerPort"), dwRTSPPort);
	//nRet = regKey.QueryValue(szRegValue, _T("RTSPServerPort"), &nActualLen);
	if(nRet != ERROR_SUCCESS)
	{
		TRACE(_T("Registry Query Fail!\r\n"));
		dwRTSPPort = 554;
	}
	regKey.Close();
	
	csRTSPProt.Format(_T("%d"), dwRTSPPort);
	this->SetDlgItemText(IDC_EDIT_RTSPSRV_PORT, csRTSPProt.GetBuffer());


	m_nHttpPort=nHttpPort;
	m_nRTSPPort=(int)dwRTSPPort;
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Example #30
0
void HandleFilterCommand(int argc, TCHAR* argv[])
{
	CRegKey FilterRegKey;
	LONG nStatus = FilterRegKey.Open(HKEY_LOCAL_MACHINE, IISXPRESSFILTER_REGKEY, KEY_READ | KEY_WRITE);
	if (nStatus != ERROR_SUCCESS)
	{		
		throw ProcessingException(MAKE_HRESULT(1, FACILITY_WIN32, nStatus), IDS_ERROR_REGISTRYPERMISSIONS);
	}

	if (argc == 2)
	{
		DWORD dwEnabled = 0;
		nStatus = FilterRegKey.QueryDWORDValue(IISXPRESS_REGKEY_ENABLED, dwEnabled);
		if (nStatus != ERROR_SUCCESS)
		{			
			throw ProcessingException(MAKE_HRESULT(1, FACILITY_WIN32, nStatus), IDS_ERROR_MISSINGIISXPRESSREGISTRY);
		}

		CString sMsg;
		if (dwEnabled != 0)
		{
			VERIFY(sMsg.LoadString(IDS_FILTERENABLED));
		}
		else
		{
			VERIFY(sMsg.LoadString(IDS_FILTERDISABLED));
		}
		
		tcout << (LPCTSTR) sMsg << _T("\n");
	}
	else if (argc == 3 && _tcsicmp(_T("enable"), argv[2]) == 0)
	{
		nStatus = FilterRegKey.SetDWORDValue(IISXPRESS_REGKEY_ENABLED, 1);
		if (nStatus != ERROR_SUCCESS)
		{
			throw ProcessingException(MAKE_HRESULT(1, FACILITY_WIN32, nStatus), IDS_ERROR_UNABLETOSETFILTERENABLESTATUS);
		}

		CString sMsg;		
		VERIFY(sMsg.LoadString(IDS_FILTERENABLED));				
		tcout << (LPCTSTR) sMsg << _T("\n");
	}
	else if (argc == 3 && _tcsicmp(_T("disable"), argv[2]) == 0)
	{
		nStatus = FilterRegKey.SetDWORDValue(IISXPRESS_REGKEY_ENABLED, 0);
		if (nStatus != ERROR_SUCCESS)
		{
			throw ProcessingException(MAKE_HRESULT(1, FACILITY_WIN32, nStatus), IDS_ERROR_UNABLETOSETFILTERENABLESTATUS);
		}		

		CString sMsg;	
		VERIFY(sMsg.LoadString(IDS_FILTERDISABLED));
		tcout << (LPCTSTR) sMsg << _T("\n");
	}
	else
	{
		CString sMsg;
		sMsg.Format(IDS_ERROR_BADPARAMETER, argv[2]);
		throw sMsg;
	}	
}