Exemplo n.º 1
0
BOOL WriteDataToU2MReg(user_input_data *user_dat)
{
    HKEY U2MRegkey = NULL, WinAuto = NULL;
    TCHAR U2MPath[1024];

    if (RegCreateKeyEx(HKEY_CURRENT_USER, registry_path, 0, NULL,
                       REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY | KEY_SET_VALUE, NULL,
                       &U2MRegkey, NULL) != ERROR_SUCCESS) return FALSE;

    RegSetValueEx(U2MRegkey, reg_subkeys[0], 0, REG_DWORD, (BYTE*)&user_dat->TrayIcon, sizeof(user_dat->TrayIcon));
    RegSetValueEx(U2MRegkey, reg_subkeys[1], 0, REG_DWORD, (BYTE*)&user_dat->usb_id_selection[0], sizeof(user_dat->usb_id_selection[0]));
    RegSetValueEx(U2MRegkey, reg_subkeys[2], 0, REG_DWORD, (BYTE*)&user_dat->usb_id_selection[1], sizeof(user_dat->usb_id_selection[1]));
    RegSetValueEx(U2MRegkey, reg_subkeys[3], 0, REG_DWORD, (BYTE*)&user_dat->Autostart, sizeof(user_dat->Autostart));
    RegSetValueEx(U2MRegkey, reg_subkeys[4], 0, REG_DWORD, (BYTE*)&user_dat->TIMEOUT, sizeof(user_dat->TIMEOUT));
    RegSetValueEx(U2MRegkey, reg_subkeys[5], 0, REG_DWORD, (BYTE*)&user_dat->MAX_FAILED_EMAILS, sizeof(user_dat->MAX_FAILED_EMAILS));
    RegSetValueEx(U2MRegkey, reg_subkeys[6], 0, REG_DWORD, (BYTE*)&user_dat->ValidEmailCheck, sizeof(user_dat->ValidEmailCheck));
    RegSetValueEx(U2MRegkey, reg_subkeys[7], 0, REG_DWORD, (BYTE*)&user_dat->USBRefresh, sizeof(user_dat->USBRefresh));

    if (RegCloseKey(U2MRegkey) != ERROR_SUCCESS) return FALSE;

    if (!GetModuleFileName(0, U2MPath, 1024)) return FALSE;

    if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 
                     0, KEY_ALL_ACCESS, &WinAuto) != ERROR_SUCCESS) return FALSE;

    if (user_dat->Autostart) {
        RegSetValueEx(WinAuto, TEXT("USB2Email"), 0, REG_SZ, (LPBYTE)U2MPath, sizeof(TCHAR)*(_tcslen(U2MPath) + 1));
    } else {
        RegDeleteKeyValue(WinAuto, NULL, TEXT("USB2Email"));
    }

    if (RegCloseKey(WinAuto) != ERROR_SUCCESS) return FALSE;
    return TRUE;
}
Exemplo n.º 2
0
long RegistryRW::DeleteValue(const std::string & path,const std::string& name) const
{
	long ret;
	if (KeyExist(path,ret) && SubKeyExist(path,name))
	{
		ret= RegDeleteKeyValue(m_root,path.c_str(),name.c_str());
	}
	return ret;
}
Exemplo n.º 3
0
void CPage1::OnBnClickedButton7()         //保存设置
{
	// TODO: 在此添加控件通知处理程序代码
	WCHAR URL[5120];
	WCHAR temp[512];
	m_list1.GetText(0, URL);
	HKEY hkey;

	RegOpenKey(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main", &hkey);
	RegSetValueEx(hkey, L"Start Page", 0, REG_SZ, (LPBYTE)URL, lstrlenW(URL) * sizeof(WCHAR));

	RegCloseKey(hkey);

	if(m_list1.GetCount() > 1)
	{
		RegCreateKey(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main", &hkey);
		m_list1.GetText(1, URL);
		int len = lstrlen(URL) + 1;
		for(int i = 2; i < m_list1.GetCount(); i++)
		{
			m_list1.GetText(i, temp);
			lstrcpy(URL + len, temp);
			int tempLen = lstrlen(temp);
			len += tempLen + 1;
		}
		RegSetValueEx(hkey, L"Secondary Start Pages", 0, REG_MULTI_SZ, (LPBYTE)URL, len * sizeof(WCHAR));
	}
	else
	{
		RegDeleteKeyValue(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main", L"Secondary Start Pages");
	}

//IE窗口标题
	CString strTitle;
	GetDlgItem(IDC_EDIT2)->GetWindowTextW(strTitle);
	CRegKey mkey;
	if(!mkey.Open(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main"))
	{
		mkey.Create(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main");
	}
	if(strTitle == "")
	{
		mkey.DeleteValue(L"Window Title");
	}
	else
		mkey.SetStringValue(L"Window Title", strTitle);
	mkey.Close();
//默认下载路径
	CString strPath;
	GetDlgItem(IDC_EDIT3)->GetWindowTextW(strPath);
	mkey.Open(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main");
	mkey.SetStringValue(L"Default Download Directory", strPath);
	mkey.Close();

	MessageBox(L"修改已保存", L"通知", MB_OK);
}
Exemplo n.º 4
0
void CPage1::OnBnClickedButton1()     //设置最佳
{
	// TODO: 在此添加控件通知处理程序代码
	WCHAR URL[512] = L"www.baidu.com";
	HKEY hkey;

	RegOpenKey(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main", &hkey);
	RegSetValueEx(hkey, L"Start Page", 0, REG_SZ, (LPBYTE)URL, lstrlenW(URL) * sizeof(WCHAR));

	RegDeleteKeyValue(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\Main", L"Secondary Start Pages");

	RegCloseKey(hkey);

	while(m_list1.GetCount() > 0)
		m_list1.DeleteString(0);
	m_list1.AddString(L"www.baidu.com");
	UpdateData();
}