Exemplo n.º 1
0
BOOL CPwSafeApp::SetStartWithWindows(BOOL bAutoStart)
{
	HKEY h = NULL;
	// TCHAR tszBuf[512];
	LONG l;

	l = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_WRITE, &h);
	if(l != ERROR_SUCCESS) return FALSE;

	if(bAutoStart == TRUE)
	{
		// GetModuleFileName(NULL, tszBuf, 510);
		std_string strPath = Executable::instance().getFullPathName();

		DWORD uPathLen = static_cast<DWORD>(strPath.length());
		if(uPathLen > 0)
		{
			if(strPath[0] != _T('\"'))
			{
				strPath = std_string(_T("\"")) + strPath + std_string(_T("\""));
				uPathLen = static_cast<DWORD>(strPath.length()); // Update length
			}
		}

		DWORD dwSize = (uPathLen + 1) * sizeof(TCHAR);
		l = RegSetValueEx(h, _T("KeePass Password Safe"), 0, REG_SZ, (LPBYTE)strPath.c_str(), dwSize);
		if(l != ERROR_SUCCESS)
		{
			RegCloseKey(h); h = NULL;
			return FALSE;
		}
	}
	else // bAutoStart == FALSE)
	{
		l = RegDeleteValue(h, _T("KeePass Password Safe"));
		if(l != ERROR_SUCCESS)
		{
			RegCloseKey(h); h = NULL;
			return FALSE;
		}
	}

	RegCloseKey(h); h = NULL;
	return TRUE;
}
Exemplo n.º 2
0
void CLanguagesDlg::OnBtnOpenFolder() 
{
	std_string str =  SU_DriveLetterToUpper(Executable::instance().getPathOnly());
	str += PWM_DIR_LANGUAGES;

	if(GetFileAttributes(str.c_str()) == INVALID_FILE_ATTRIBUTES)
		CreateDirectory(str.c_str(), NULL);

	str = std_string(_T("cmd://\"")) + str + _T("\"");
	OpenUrlEx(str.c_str(), this->m_hWnd);
	OnCancel();
}
Msg::ObjectMsgCall * Server::ServerHandler::SlaveStartAuth_RpcServer(INT32 nSessionID , Msg::Object objSrc , std_string &name/* = std::string()*/ , std_string & pwd/* = std::string()*/  )
{
	std_string value = std::string();

	GameDB::Database * pDB = GetDBServer()->GetEnvironment()->GetDatabase(g_szSystemDatabase);
	if (!pDB)
	{ 
		Return(value);
	} 

	GameDB::Operate oper;
	GameDB::HashTable::HGet(*pDB , oper , GameDB::User::TableName() , name);
	if (!oper.IsSuccess())
	{
		gDebugStream("DB:" <<  g_szSystemDatabase << " table:" <<  g_szSystemDatabase << "name:" << name << "failure.");
		Return(value);
	}  
	 
	oper.GetOperateReturns().GetStream() >> value;
	if (value.length() <= 0)
	{
		gDebugStream("DB:" << g_szSystemDatabase << "table:" << g_szSystemDatabase << "key:" << name << "failure.");
		Return(std_string());
	} 

	GameDB::User objUser;
	objUser.FromBson(value.c_str() , (INT32)value.length()); 

	if(objUser.get_pswd() != pwd)
	{ 
		gDebugStream("DB:" << g_szSystemDatabase << "table:" << g_szSystemDatabase << "key:" << name << "password wrong.");
		Return(std_string()); 
	}
	 
	std::cout << "SlaveStartAuth_RpcServer "<< std::endl;
	Return(value);
}
Exemplo n.º 4
0
std_string CKeySourcesPool::Get(LPCTSTR lpDatabasePath)
{
	if(lpDatabasePath == NULL) { ASSERT(FALSE); return std_string(); }

	if(m_bEnabled == FALSE) return std_string();

	CString strWanted = lpDatabasePath;
	strWanted = strWanted.Trim();

	for(KspVec::iterator it = m_vec.begin(); it != m_vec.end(); ++it)
	{
		CString strKey = it->first.c_str();
		strKey = strKey.Trim();

		if(strKey.CompareNoCase(strWanted) == 0)
		{
			std_string strRet = it->second;
			CKeySourcesPool::_UpdateItem(it);
			return strRet;
		}
	}

	return std_string();
}