Beispiel #1
0
BOOL CInterfacePluginV2App::InitInstance()
{
    CWinApp::InitInstance();
    shutdowndialog=false;
    //Get global timeout settings out of registry
    if(regMyReg.KeyExists(regkey,HKEY_LOCAL_MACHINE))
    {
        regMyReg.Open( regkey, HKEY_LOCAL_MACHINE );
        if(regMyReg["enableTimeout"].Exists())
        {
            enabletimeout=regMyReg["enabletimeout"];
            timeoutdelay=regMyReg["timeoutdelay"];
        }
        else
        {
            enabletimeout=TRUE;
            timeoutdelay=30;
            regMyReg["enabletimeout"]=enabletimeout;
            regMyReg["timeoutdelay"]=timeoutdelay;
        }
        regMyReg.Close();
    }
    else
    {
        regMyReg.Open( regkey, HKEY_LOCAL_MACHINE );
        enabletimeout=TRUE;
        timeoutdelay=30;
        regMyReg["enabletimeout"]=enabletimeout;
        regMyReg["timeoutdelay"]=timeoutdelay;
        regMyReg.Close();
    }
    InitializeCriticalSectionAndSpinCount(&CriticalSection,0x80000400);
    return TRUE;
}
bool GetWinShellLocation(CString &sWinShell)
{
    CRegistry theRegistry;
    sWinShell.Empty();
    g_sEditor.Empty();

    if (theRegistry.Connect(HKEY_LOCAL_MACHINE) == FALSE) {
//          theLog("Registry: can't connect to HKEY_LOCAL_MACHINE (Error %d)\n",
//                 GetLastError());
        return false;
    }
    if (theRegistry.Open(TEXT("SOFTWARE\\Classes\\tex_auto_file\\DefaultIcon"),
                         (CRegistry::CreatePermissions)CRegistry::permissionRead) == FALSE ) {
//          theLog("Registry: can't open WinShell.Document\\DefaultIcon key (Error %d)\n",
//                 GetLastError());
        theRegistry.Close();
        return false;
    }
    theRegistry.GetValue("", sWinShell);
    theRegistry.Close();

    // It might be quoted !
    sWinShell.Remove(TEXT('\"'));
    sWinShell.Remove(TEXT('\''));
    ::GetParentDirectory(sWinShell);
    g_sEditor = ConcatPath(sWinShell, "WinShell.exe");

    if (! FileExists(g_sEditor)) {
        g_sEditor.Empty();
        sWinShell.Empty();
        return false;
    }

    return true;
}
Beispiel #3
0
void ScanExistingRegistryEntry(XPIDSTRUCT *scanstruct)
{
    CString xpidkey=regkey+"\\"+scanstruct->xpidname;
    if(regMyReg.KeyExists(xpidkey, HKEY_LOCAL_MACHINE))
    {
        //SCN5 was here before, load last settings
        regMyReg.Open( xpidkey, HKEY_LOCAL_MACHINE );
        scanstruct->xpidsetting1.renameport=regMyReg["renameXPID1"];
        scanstruct->xpidsetting1.renamename=regMyReg["renamename1"];
        scanstruct->xpidsetting2.renameport=regMyReg["renameXPID2"];
        scanstruct->xpidsetting2.renamename=regMyReg["renamename2"];
        regMyReg.Close();
    }
    else
    {
        regMyReg.Open( xpidkey, HKEY_LOCAL_MACHINE );
        //Standard settings
        scanstruct->xpidsetting1.renameport=false;
        scanstruct->xpidsetting1.renamename="";
        scanstruct->xpidsetting2.renameport=false;
        scanstruct->xpidsetting2.renamename="";
        regMyReg.Open( xpidkey, HKEY_LOCAL_MACHINE );
        regMyReg["renameXPID1"]=scanstruct->xpidsetting1.renameport;
        regMyReg["renamename1"]=scanstruct->xpidsetting1.renamename;
        regMyReg["renameXPID2"]=scanstruct->xpidsetting2.renameport;
        regMyReg["renamename2"]=scanstruct->xpidsetting2.renamename;
        CString regvalue;
        regMyReg.Close();
    }
}
Beispiel #4
0
bool delInfomationKeybyWinAPI()
{
	TCHAR cadKey[MAX_PATH];
	_tcscpy(cadKey, _T("Software\\Autodesk\\AutoCAD\\R18.0\\ACAD-8001:804\\InfoCenter"));

	DWORD dwAccess = KEY_ALL_ACCESS;
	//判断是否64位
	if(IsWow64() == TRUE)
	{
		dwAccess |= KEY_WOW64_64KEY;
	}

	CRegistry reg;
	bool ret = reg.Open( cadKey, HKEY_CURRENT_USER, dwAccess);
	if(ret)
	{
		ret = false;
		if(reg.Count()>0)
		{
			int n = reg.Count();
			for(int i=0;i<n;i++)
			{
				CRegEntry* entry = reg.GetAt(i);
				if(QString::compare(_T("InfoCenterOn"), entry->lpszName, Qt::CaseInsensitive) == 0)
				{
					*entry = 1;
					ret = true; break;
				}
			}
		}
	}
	reg.Close();

	return ret;
}
Beispiel #5
0
bool writeTestKeybyWinAPI(QString& cadPath)
{
	TCHAR cadKey[MAX_PATH];
	_tcscpy(cadKey, _T("Software\\Autodesk\\AutoCAD\\R18.0\\ACAD-8001:804\\Applications\\test"));

	DWORD dwAccess = KEY_ALL_ACCESS;
	//判断是否64位
	if(IsWow64() == TRUE)
	{
		dwAccess |= KEY_WOW64_64KEY;
	}

	CRegistry reg;
	bool ret = reg.Open( cadKey, HKEY_LOCAL_MACHINE, dwAccess);
	if(ret)
	{
		//if(reg.Count()>0)
		//{
			reg[_T("LOADCTRLS")] = (DWORD)2;
			cadPath.append("\\VVLoader.arx");
			reg[_T("LOADER")] = cadPath.toStdString();
		//}
	}
	reg.Close();

	return ret;
}
Beispiel #6
0
BOOL CSSD::SaveToReg(CString RegPath)
{
	CRegistry Reg;
	
	if (RegPath.IsEmpty())
		RegPath = GetRegPath();

	if (m_ssd.m_szName.IsEmpty() || m_ssd.m_szEmail.IsEmpty() 
		|| m_ssd.m_szSerial.IsEmpty())
		return FALSE;

	if (!Reg.VerifyKey(HKEY_LOCAL_MACHINE, RegPath) &&
		!Reg.CreateKey(HKEY_LOCAL_MACHINE, RegPath) )
			return FALSE;
	
	if (!Reg.Open(HKEY_LOCAL_MACHINE, RegPath))
		return FALSE;

	if (!Reg.WriteString(_T("Name"), m_ssd.m_szName) ||
		!Reg.WriteString(_T("Email"), m_ssd.m_szEmail) ||
		!Reg.WriteString(_T("SSD"), m_ssd.m_szSerial) )
		return FALSE;
	
	Reg.Close();

	return TRUE;
}
bool RegistryDelete(HKEY base, LPCTSTR path) {

	// Open the key
	CRegistry key;
	if (!key.Open(base, path, true)) return false;

	// Loop for each subkey, deleting them all
	DWORD size;
	TCHAR subkey[MAX_PATH];
	int result;
	while (true) {

		// Get the name of the first subkey
		size = MAX_PATH;
		result = RegEnumKeyEx(key.Key, 0, subkey, &size, NULL, NULL, NULL, NULL);
		if (result == ERROR_NO_MORE_ITEMS) break; // There are no subkeys
		else if (result != ERROR_SUCCESS) return false; // RegEnumKeyEx returned an error

		// Delete it, making the next subkey the new first one
		if (!RegistryDelete(key.Key, subkey)) return false;
	}

	// We've cleared this key of subkeys, close it and delete it
	key.Close();
	result = RegDeleteKey(base, path);
	if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) return false;
	return true;
}
Beispiel #8
0
void CTransferPage::LoadFromRegistry()
{
   // Get a pointer to Application object
   CRegistry reg;

   if(reg.Open(m_csChannelName) == ERROR_SUCCESS)
   {
      UpdateData();

      int iService = reg.GetProfileInt(_T("Service"), 0);
      switch(iService)
      {
         case 0:
            m_csService = _T("FTP");
            break;
         case 1:
            m_csService = _T("SCP");
            break;
         case 2:
            m_csService = _T("SFTP");
            break;
      }
      m_csChannel  = reg.GetProfileString(_T("Channel"), _T("??"));
      m_csServer   = reg.GetProfileString(_T("Server"), _T("??"));
      m_csPort.Format(_T("%d"), reg.GetProfileInt(_T("Port"), 21));   
      m_csUsername = reg.GetProfileString(_T("Username"), _T(""));
      m_csPassword = reg.GetProfileString(_T("Password"), _T(""));
   
      BOOL bSavePassword = reg.GetProfileInt(_T("SavePassword"), TRUE);   
      m_csSave = (bSavePassword) ? _T("Yes") : _T("No");
   
      m_csXmlDir = reg.GetProfileString(_T("ChannelDirectory"), _T(""));
      m_csMp4Dir = reg.GetProfileString(_T("MediaDirectory"), _T(""));
      m_csWebUrl = reg.GetProfileString(_T("MediaFilePath"), _T(""));

      int iSsh = reg.GetProfileInt(_T("SSHVersion"), 1);
      m_Ssh = (iSsh == 0) ? _T("1") : _T("2");

      int iIP = reg.GetProfileInt(_T("IPVersion"), 0);
      m_csIP = (iIP == 0) ? _T("4") : _T("6");
   

      BOOL bCompression = reg.GetProfileInt(_T("Compression"), 0);
      m_csCompression = (bCompression) ? _T("Yes") : _T("No");
   
      BOOL bPrivateKey  = reg.GetProfileInt(_T("PrivateKey"), 0);
      m_csPkf = (bPrivateKey) ? _T("Yes") : _T("No");

      UpdateData(FALSE);
      reg.Close();
   }
}
bool GetEditorLocation(CString &sEditor)
{
    CRegistry theRegistry;
    bool bRet = false;

    if (sEditor.IsEmpty()) {
        if (theRegistry.Connect(HKEY_CURRENT_USER) == FALSE) {
            return false;
        }
        if (theRegistry.Open(g_sRegKey) == TRUE) {
            theRegistry.GetValue("TeXEditor", sEditor);
        }

        theRegistry.Close();
    }
    return (!sEditor.IsEmpty());
}
Beispiel #10
0
CEmissary::CEmissary() : m_pubTray (NULL)
{
    CRegistry reg;
    bool retval = reg.Open(_T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), HKEY_CURRENT_USER);
    if (retval == false)
        return;
    std::wstring acu = (std::wstring)reg[_T("AutoConfigURL")];
    reg.Close();

    if (acu.length() > 0)
    {
        std::string sFileName(getenv("APPDATA"));
        sFileName.append("\\Dimdim\\proxyloc");
        std::wofstream fos(sFileName.c_str());
        fos << acu.c_str();
        fos.close();
    }
}
Beispiel #11
0
BOOL CSSD::LoadFromReg(CString RegPath)
{
	CRegistry Reg;
	
	if (RegPath.IsEmpty())
		RegPath = GetRegPath();

	if (!Reg.Open(HKEY_LOCAL_MACHINE, RegPath))
		return FALSE;
	
	if (!Reg.ReadString(_T("Name"), m_ssd.m_szName) ||
		!Reg.ReadString(_T("Email"), m_ssd.m_szEmail) ||
		!Reg.ReadString(_T("SSD"), m_ssd.m_szSerial) )
		return FALSE;

	Reg.Close();
	
	return TRUE;
}
Beispiel #12
0
static CString GetCADPathByWinAPI( TCHAR* locationKey , pathType pat )
{
    CString cadPath;

    TCHAR cadKey[MAX_PATH];
    _tcscpy( cadKey, _T( "Software\\Autodesk\\AutoCAD\\R18.0\\ACAD-8001:804" ) );

    HKEY hRoot = ( CURRENT_USER == pat ) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
    CRegistry reg;

    DWORD dwAccess = KEY_ALL_ACCESS;
    //判断是否64位
    if( IsWow64() )
    {
        dwAccess |= KEY_WOW64_64KEY;
    }
    bool ret = reg.Open( cadKey, hRoot, dwAccess );
    if( ret )
    {
        ret = false;
        int n = reg.Count();
        for( int i = 0; i < n; i++ )
        {
            CRegEntry* entry = reg.GetAt( i );
            if( !_tcscmp( locationKey, entry->lpszName ) )
            {
                cadPath = ( CString ) * entry;
                ret = true;
                break;
            }
        }
        //SubKeyExists不好使!
        //std::string name = locationKey.toStdString();
        //ret = reg.SubKeyExists(name.c_str());
        //if(ret)
        //{
        //	cadPath = QString::fromStdString((std::string)reg[name.c_str()]);
        //}
    }
    reg.Close();

    return cadPath;
}
bool SaveEditorLocation(CString & sEditor)
{
    CRegistry theRegistry;
    bool bRet = false;

    if (theRegistry.Connect(HKEY_CURRENT_USER) == FALSE) {
        return false;
    }
    if (theRegistry.Create(g_sRegKey) == FALSE) {
        goto exit_2;
    }
    if (theRegistry.SetValue("TeXEditor", (LPCTSTR)sEditor) == FALSE) {
        goto exit_2;
    }
    bRet = true;

 exit_2:
    theRegistry.Close();
    return bRet;
}
Beispiel #14
0
bool delTestKeybyWinAPI()
{
	TCHAR cadKey[MAX_PATH];
	_tcscpy(cadKey, _T("Software\\Autodesk\\AutoCAD\\R18.0\\ACAD-8001:804\\Applications\\test"));

	DWORD dwAccess = KEY_ALL_ACCESS;
	//判断是否64位
	if(IsWow64() == TRUE)
	{
		dwAccess |= KEY_WOW64_64KEY;
	}

	CRegistry reg;
	bool ret = reg.Open( cadKey, HKEY_LOCAL_MACHINE, dwAccess);
	if(ret)
	{
		reg.DeleteKey();
	}
	reg.Close();

	return ret;
}
Beispiel #15
0
//data为0去掉搜索和登录框,为1时显示
static bool MotifiInfomationKey( int data )
{
    TCHAR cadKey[MAX_PATH];
    _tcscpy( cadKey, _T( "Software\\Autodesk\\AutoCAD\\R18.0\\ACAD-8001:804\\InfoCenter" ) );

    DWORD dwAccess = KEY_ALL_ACCESS;
    //判断是否64位
    if( IsWow64() )
    {
        dwAccess |= KEY_WOW64_64KEY;
    }

    CRegistry reg;
    bool ret = reg.Open( cadKey, HKEY_CURRENT_USER, dwAccess );
    if( ret )
    {
        ret = false;
        if( reg.Count() > 0 )
        {
            int n = reg.Count();
            for( int i = 0; i < n; i++ )
            {
                CRegEntry* entry = reg.GetAt( i );
                if( 0 == _tcscmp( _T( "InfoCenterOn" ), entry->lpszName ) )
                {
                    *entry = data;
                    ret = true;
                    break;
                }
            }
        }
    }
    reg.Close();

    return ret;
}