Esempio n. 1
0
void NS_ISERVER::CLocalServer::LocalAuditUserQuit(CString strTermID, CString strIP,UINT nMemberID)
{
	NET_HEAD_MAN head = {0};
	head.Version = COM_VER;
	head.Length = sizeof TIBAAuditUserQuit;
	head.Cmd = C_MANGER_AUDITUSERQUIT;

	TIBAAuditUserQuit info = {0};

	_snprintf(info.termID, LEN_TERMID, CT2A(strTermID));
	_snprintf(info.termIP, LEN_IPADDR, CT2A(strIP));
	info.memberID=nMemberID;

	CByteArray buffer;
	buffer.SetSize(sizeof NET_HEAD_MAN + head.Length);

	memcpy(buffer.GetData(), &head, sizeof NET_HEAD_MAN);
	memcpy(buffer.GetData() + sizeof NET_HEAD_MAN, &info, sizeof TIBAAuditUserQuit);

	m_lpSocket->SendBuffer(buffer.GetData(), buffer.GetSize());

	buffer.RemoveAll();

	IBA_LOG(_T("发送实名下机信息,TermID=%s,IP=%s,MemberID=%d"),strTermID,strIP,nMemberID);
}
Esempio n. 2
0
	void CPlugin::SetFirefoxCookie(const vector<SetFirefoxCookieParams>& vCookies, ULONG_PTR ulWindowId)
	{
		CString strEventType = _T("IEBatchSetCookie");
		CString strDetail;
		Json::Value json;
		Json::Value aCookies;
		for (size_t i = 0; i < vCookies.size(); i++)
		{
			const SetFirefoxCookieParams& param = vCookies[i];
			Json::Value cookie;
			cookie["url"] = (LPCSTR)CT2A(param.strURL, CP_UTF8);
			cookie["header"] = (LPCSTR)CT2A(param.strCookie, CP_UTF8);
			aCookies.append(cookie);
		}
		json["cookies"] = aCookies;

		if (ulWindowId)
		{
			char szWindowId[32] = { 0 };
			_ui64toa_s(ulWindowId, szWindowId, 32, 10);
			json["windowId"] = szWindowId;
		}

		strDetail = CA2T(json.toStyledString().c_str(), CP_UTF8);
		FireEvent(strEventType, strDetail);
	}
Esempio n. 3
0
BOOL __stdcall ComDlgHistoryLog::EnumValue( LPCTSTR value_name, ULONG value_type, UCHAR* value, ULONG value_size, PVOID context )
{
    Json::Value *log_value = (Json::Value *)context;
    if (value_type == REG_BINARY) {
        if (_tcscmp(TEXT("MRUListEx"), value_name) != 0) {
            LPITEMIDLIST file_pidl = (LPITEMIDLIST)CoTaskMemAlloc(sizeof(UCHAR) + value_size);

            if (file_pidl) {
                memcpy(file_pidl, value, value_size);
                WCHAR mru_file_path[MAX_PATH] = { 0 };
                if (SHGetPathFromIDList(file_pidl, mru_file_path)) {
                    Json::Value item;
                    item["path"] = CT2A(mru_file_path).m_psz;
                    log_value->append(item);
                }
                CoTaskMemFree(file_pidl);
            }
        }
    }
    else if (value_type == REG_SZ) {
        if (_tcscmp(TEXT("MRUList"), value_name) != 0) {
            PWSTR mru_file_path = (PWSTR)value;
            Json::Value item;
            item["path"] = CT2A(mru_file_path).m_psz;
            log_value->append(item);
        }
    }
    
    return TRUE;
}
bool CWordBinaryMetadataDiscoveryWorker::PopulatePropertyLists(CWordBinaryMetadataDiscoveryWorker::WordPropertyTypes WordPropertyType, CStdString& sPropertyName, CStdString& sPropertyValue)
{
	USES_CONVERSION;
	switch(WordPropertyType)
	{
		case BUILT_IN_PROPERTY:
			if(sPropertyName.IsEmpty())
				return true;
			
			if (c_sHyperLinkBasePropertyName == std::string(CT2A(sPropertyName.c_str())) )
				sPropertyName = _T("Hyperlink base");
			else if (c_sHyperLinksPropertyName == std::string(CT2A(sPropertyName.c_str())) )
				return true;
			
			m_BuiltInPropertiesMap.insert(PropertyMapType::value_type(sPropertyName, sPropertyValue));
			m_lBuiltInPropertyCount++;
			break;

		case CUSTOM_PROPERTY:
			m_CustomPropertiesMap.insert(PropertyMapType::value_type(sPropertyName, sPropertyValue));
			m_lCustomPropertyCount++;
			break;

		case DOCUMENT_STATISTIC:
			m_DocumentStatisticsMap.insert(PropertyMapType::value_type(sPropertyName, sPropertyValue));
			m_lDocumentStatisticsCount++;
			break;

		default:
			LOG_WS_ERROR(_T("Unknown WordPropertyTypes passed as parameter"));
			return false;
	}
	return true;
}
Esempio n. 5
0
File: XML.cpp Progetto: GetEnvy/Envy
BOOL CXMLElement::Merge(const CXMLElement* pInput, BOOL bOverwrite)
{
	if ( ! this || ! pInput ) return FALSE;
	if ( this == pInput ) return TRUE;

	TRACE( "Merging   XML: %s\n", (LPCSTR)CT2A( ToString( FALSE, FALSE ) ) );
	TRACE( "      and XML: %s\n", (LPCSTR)CT2A( pInput->ToString( FALSE, FALSE ) ) );

	if ( m_sName.CompareNoCase( pInput->m_sName ) != 0 )
	{
		TRACE( "Failed to merge XML due different schemes \"%s\" and \"%s\".\n", (LPCSTR)CT2A( m_sName ), (LPCSTR)CT2A( pInput->m_sName ) );
		return FALSE;
	}

	BOOL bChanged = FALSE;

	for ( POSITION pos = pInput->GetElementIterator(); pos; )
	{
		const CXMLElement* pElement = pInput->GetNextElement( pos );
		CXMLElement* pTarget = GetElementByName( pElement->m_sName );

		if ( pTarget == NULL )
		{
			AddElement( pElement->Clone() );
			bChanged = TRUE;
		}
		else if ( pTarget->Merge( pElement, bOverwrite ) )
		{
			bChanged = TRUE;
		}
	}

	for ( POSITION pos = pInput->GetAttributeIterator(); pos; )
	{
		CXMLAttribute* pAttribute = pInput->GetNextAttribute( pos );
		CXMLAttribute* pTarget = GetAttribute( pAttribute->m_sName );

		if ( pTarget == NULL )
		{
			AddAttribute( pAttribute->Clone() );
			bChanged = TRUE;
		}
		else if ( bOverwrite && ! pTarget->Equals( pAttribute ) )
		{
			pTarget->SetValue( pAttribute->GetValue() );
			bChanged = TRUE;
		}
	}

	if ( bChanged )
		TRACE( "resulting XML: %s\n", (LPCSTR)CT2A( ToString( FALSE, FALSE ) ) );
	else
		TRACE( "resulting XML unchanged.\n" );

	return bChanged;
}
Esempio n. 6
0
void Rectan::Save(ofstream& out)
{
	int x = min(m_x1, m_x2);
	int y = min(m_y1, m_y2);
	int width = abs(m_x1 - m_x2);
	int height = abs(m_y1 - m_y2);
	CString temp;
	temp.Format(_T(" fill=\"rgb(%d, %d, %d)\""), m_Background_Color.GetRed(), m_Background_Color.GetGreen(), m_Background_Color.GetBlue());
	out << "<rect x=\"" << x << "\" y=\"" << y << "\" width=\"" << width << "\" height=\"" << height << "\"";
	out << CT2A(temp);
	temp.Format(_T(" stroke=\"rgb(%d, %d, %d)\""), m_Color.GetRed(), m_Color.GetGreen(), m_Color.GetBlue());
	out << CT2A(temp);
	out << " stroke-width=\"" << m_Width << "\" />";
}
Esempio n. 7
0
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
bool CWinInetEvents::RegexMatch(CString str, CString regex) {
  bool matched = false;

  if (str.GetLength()) {
    if (!regex.GetLength() || !regex.Compare(_T("*")) || !str.CompareNoCase(regex)) {
      matched = true;
    } else if (regex.GetLength()) {
        std::tr1::regex match_regex(CT2A(regex), std::tr1::regex_constants::icase | std::tr1::regex_constants::ECMAScript);
        matched = std::tr1::regex_match((LPCSTR)CT2A(str), match_regex);
    }
  }

  return matched;
}
Esempio n. 8
0
int _tmain(int argc, _TCHAR* argv[])
{
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	IODispatcher ioService(GetFitThreadNum());
	

	try
	{
		std::string ip;
		if( argc > 1 )
			ip = CT2A(argv[1]);
		else
			ip = "127.0.0.1";

		std::vector<Client *> clis;
		size_t cnt = 1;
		if( argc > 2 )
			cnt = _tstoi(argv[2]);

		clis.resize(cnt);
		for(size_t i = 0; i != cnt; ++i)
			clis.push_back(new Client(ioService, ip.c_str(), 5050));


		system("pause");
	}
	catch(std::exception &e)
	{
		std::cout << e.what() << std::endl;
	}
	
	return 0;
}
Esempio n. 9
0
void CVNOCLoginDlg::OnBnClickedOk()
{
    UpdateData(TRUE);
	Global->Logf(LogFile_Net,_T("登陆操作,用户名:%s 密码:%s\n"), m_strUsername, m_strPassword);
	if (m_strUsername.IsEmpty())
	{
		OnOK();
	}

	SHA1 shaer;
	shaer.Reset();

	CStringA pwdBuffer = CT2A(m_strPassword);
	shaer.Input(pwdBuffer,pwdBuffer.GetLength());
	UINT pResult[5];
	shaer.Result(pResult);
	pwdBuffer.Format("%08x%08x%08x%08x%08x"
		,pResult[0],pResult[1],pResult[2],pResult[3],pResult[4]);
	Global->Logf(LogFile_General,_T("SHA1后的密码为:%s\n"),CA2T(pwdBuffer));

	INetCenter *pInet=NULL;
	Global->GetINetCenter(&pInet);
	ATLASSERT(pInet);
	if (pInet)
	{
		MSG_RLI mRli;
		mRli.SetAccountNumber((byte*)(LPCTSTR)m_strUsername,m_strUsername.GetLength()*sizeof(TCHAR));
		mRli.SetPassword((byte*)(LPCSTR)pwdBuffer,pwdBuffer.GetLength()*sizeof(TCHAR));
		pInet->SendServer(mRli);

		_SetVerifyState(TRUE);
		SetTimer(0,5000,NULL);
	}
}
Esempio n. 10
0
CTransferFile* CTransferFiles::Open(LPCTSTR pszFile, BOOL bWrite)
{
	CSingleLock pLock( &m_pSection, TRUE );

	CTransferFile* pFile = NULL;
	if ( m_pMap.Lookup( pszFile, pFile ) )
	{
		if ( bWrite && ! pFile->EnsureWrite() )
			return NULL;
	
		pFile->AddRef();
	}
	else
	{
		pFile = new CTransferFile( pszFile );
		if ( ! pFile->Open( bWrite ) )
		{
			DWORD dwError = GetLastError();
			pFile->Release();
			SetLastError( dwError );
			return NULL;
		}

		m_pMap.SetAt( pFile->m_sPath, pFile );

		TRACE( "Transfer Files : Opened \"%s\" [%s]\n", (LPCSTR)CT2A( pszFile ), ( bWrite ? "write" : "read" ) );
	}

	return pFile;
}
Esempio n. 11
0
 void Restore(IPersistable * window) const
 {
     clib::recursive_mutex::scoped_lock lock(m_mutex);
     WINDOWPLACEMENT placement;
     std::string encodedStr = CT2A(m_props.Get(PERSIST_PLACEMENT));
     int decodedLen = sizeof(WINDOWPLACEMENT);
     BOOL hr = Base64Decode(encodedStr.c_str(), encodedStr.length(), reinterpret_cast<BYTE *>(&placement), &decodedLen);
     if (hr && placement.length == sizeof(WINDOWPLACEMENT))
     {
         if (placement.showCmd == SW_SHOWMINIMIZED)
         {
             //(Prevent Launch To Minimized)
             placement.showCmd = SW_SHOWNORMAL;
         }
         RECT rMaxWA;
         ::SystemParametersInfo(SPI_GETWORKAREA, 0, &rMaxWA, 0);
         if( (placement.rcNormalPosition.left >= rMaxWA.left) &&
             (placement.rcNormalPosition.top >= rMaxWA.top) &&
             (placement.rcNormalPosition.right <= rMaxWA.right) &&
             (placement.rcNormalPosition.bottom <= rMaxWA.bottom) )
         {
             // If All Values Within The Visible Screen (Taking Into Account Only The Primary Monitor...!), Set The Placement
             ::SetWindowPlacement(window->GetHwnd(), &placement);
         }
     }
     window->RestorePersistInfo(m_props);
 }
Esempio n. 12
0
BOOL CCPPhDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	
	this->flog.open(_T("cpph.log")); //open log

	SetTimer(1, 1000, 0); //timer to show minutes to close

	//established token
	this->established_token_status = this->token.establish_token();
	TCHAR msg_char[200];
	if (this->established_token_status == 0){
		this->token.list_containers(this->token_containeres);
		if (this->cur_container_name != this->token_containeres[this->cur_container_id]){ //if not displayed, show it
			wsprintf(msg_char, _T("%s \"%S\""), STATIC_TEXT_1, this->token_containeres[this->cur_container_id].c_str());
			mMsg.SetWindowTextW(msg_char);
			this->cur_container_name = this->token_containeres[this->cur_container_id];
			this->flog << this->loctime() << ": Established container: " << this->cur_container_name << endl; //log
		}
	}
	
	TCHAR l[100];
	GetKeyboardLayoutName(l);
	this->flog << this->loctime() << ": Current leyboard layout: " << CT2A(l) << endl;

	return TRUE;  // return TRUE  unless you set the focus to a control
}
Esempio n. 13
0
void CThumbCache::InitDatabase()
{
	auto_ptr< CDatabase > db( theApp.GetDatabase( DB_THUMBS ) );
	if ( ! *db )
	{
		TRACE( "CThumbCache::InitDatabase : Database error: %s\n", (LPCSTR)CT2A( db->GetLastErrorMessage() ) );
		return;
	}

	// Recreate table
	if ( ! db->Exec( L"CREATE TABLE Files ("
			 L"Filename TEXT UNIQUE NOT NULL PRIMARY KEY, "
			 L"FileSize INTEGER NOT NULL, "
			 L"LastWriteTime INTEGER NOT NULL, "
			 L"Image BLOB NOT NULL, "	// as JPEG
			 L"Flags INTEGER DEFAULT 0 NULL, "
			 L"SHA1 TEXT NULL, TTH TEXT NULL, ED2K TEXT NULL, MD5 TEXT NULL); "
			 L"CREATE INDEX IDX_SHA1 ON Files(SHA1 ASC); "
			 L"CREATE INDEX IDX_TTH ON Files(TTH ASC); "
			 L"CREATE INDEX IDX_ED2K ON Files(ED2K ASC); "
			 L"CREATE INDEX IDX_MD5 ON Files(MD5 ASC);" ) )
	{
		// Cleanup existing
		//TIMER_START
		theApp.KeepAlive();
		db->Exec( L"PRAGMA synchronous=OFF" );		// Async return (15% faster, ~1sec)
		db->Exec( L"PRAGMA journal_mode=OFF" );		// No temp "-journal" rollback file created (2X time)
		db->Exec( L"VACUUM;" );						// Several seconds if large
		theApp.KeepAlive();
		//TIMER_STOP
	}
}
Esempio n. 14
0
BOOL IsIPAddress(LPCTSTR lpszAddress)
{
	if(!lpszAddress || lpszAddress[0] == '\0')
		return FALSE;

	return ::inet_addr(CT2A(lpszAddress)) != INADDR_NONE;
}
CString CodePassword(LPCTSTR decrypted)
{
	CString crypted;
	char cDecrypted[256] = { 0 };
	strcpy(cDecrypted, CT2A(decrypted));
	char *p = cDecrypted;
	while (*p != '\0')
	{
		for (int i = 0; i < 256; i++)
		{
			if (*p == CodeBook[i])
			{
				TCHAR code[3] = {0};
				wsprintf((LPWSTR)code, _T("%02x"), i);
				crypted.AppendChar(code[0]);
				crypted.AppendChar(code[1]);
				break;
			}
		}

		p++;
	}

	return crypted;
}
Esempio n. 16
0
BOOL CYYApiMgr::Rename(CString nick)
{
	if (g_pYYExApi == NULL)
	{
		return FALSE;
	}

	yy::IUserEx* pUser = g_pYYExApi->GetUser();
	if (pUser == NULL)
	{
		return FALSE;
	}

	if (nick.GetLength() > max_nick_length)
	{
		nick.Delete(max_nick_length, nick.GetLength()-max_nick_length);
	}

	char name[256] = {0};
	strcpy(name, CT2A(nick, CP_UTF8));
	unsigned int nError = pUser->Rename(name);
	if (nError != yy_success)
	{
		return FALSE;
	}

	return TRUE;
}
Esempio n. 17
0
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
int	CWsHook::getaddrinfo(PCSTR pNodeName, PCSTR pServiceName, const ADDRINFOA * pHints, PADDRINFOA * ppResult)
{
	int ret = WSAEINVAL;
	bool overrideDNS = false;

	void * context = NULL;
	CString name = CA2T(pNodeName);
	CAtlArray<DWORD> addresses;
	if( dlg )
		overrideDNS = dlg->DnsLookupStart( name, context, addresses );

	if( _getaddrinfo && !overrideDNS )
		ret = _getaddrinfo(CT2A((LPCTSTR)name), pServiceName, pHints, ppResult);
	else if( overrideDNS ) {
		if( addresses.IsEmpty() )
			ret = EAI_NONAME;
		else {
			// build the response structure with the addresses we looked up
			ret = 0;
			DWORD count = addresses.GetCount();

			ADDRINFOA_ADDR * result = (ADDRINFOA_ADDR *)malloc(sizeof(ADDRINFOA_ADDR) * count);
			for (DWORD i = 0; i < count; i++) {
				memset( &result[i], 0, sizeof(ADDRINFOA_ADDR) );
				result->info.ai_family = AF_INET;
				result->info.ai_addrlen = sizeof(struct sockaddr_in);
				result->info.ai_addr = (struct sockaddr *)&(result->addr);
				result->addr.sin_family = AF_INET;
				result->addr.sin_addr.S_un.S_addr = addresses[i];
				if( i < count - 1 )
					result->info.ai_next = (PADDRINFOA)&result[i+1];
			}
			addrInfo.AddTail(result);

			*ppResult = (PADDRINFOA)result;
		}
	}

	if (!ret && dlg) {
		PADDRINFOA addr = *ppResult;
		while (addr) {
      if (addr->ai_canonname)
        dlg->DnsLookupAlias(name, (LPCTSTR)CA2T(addr->ai_canonname));

			if (context &&
          addr->ai_addrlen >= sizeof(struct sockaddr_in) && 
          addr->ai_family == AF_INET) {
				struct sockaddr_in * ipName = (struct sockaddr_in *)addr->ai_addr;
				dlg->DnsLookupAddress(context, ipName->sin_addr);
			}

			addr = addr->ai_next;
		}

    if (context)
		  dlg->DnsLookupDone(context);
	}

	return ret;
}
Esempio n. 18
0
BOOL CIocpServer::CreateListenSocket(LPCTSTR pszBindAddress, USHORT usPort)
{
	BOOL isOK = FALSE;

	m_soListen	= socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if(m_soListen != INVALID_SOCKET)
	{
		SOCKADDR_IN addr;
		addr.sin_family			= AF_INET;
		addr.sin_addr.s_addr	= inet_addr(CT2A(pszBindAddress));
		addr.sin_port			= ::htons(usPort);

		if(::bind(m_soListen, (SOCKADDR*)&addr, sizeof(SOCKADDR_IN)) != SOCKET_ERROR)
		{
			if(::listen(m_soListen, m_dwSocketListenQueue) != SOCKET_ERROR)
			{
				m_pfnAcceptEx				= ::Get_AcceptEx_FuncPtr(m_soListen);  //取得接收扩展函数AcceptEx指针
				m_pfnGetAcceptExSockaddrs	= ::Get_GetAcceptExSockaddrs_FuncPtr(m_soListen);//最得GetAcceptExSockaddrs扩展函数指针

				ASSERT(m_pfnAcceptEx);
				ASSERT(m_pfnGetAcceptExSockaddrs);

				isOK = TRUE;
			}
			else
				SetLastError(ISS_SOCKET_LISTEN, _T(__FUNCTION__), ::WSAGetLastError());
		}
		else
			SetLastError(ISS_SOCKET_BIND, _T(__FUNCTION__), ::WSAGetLastError());
	}
	else
		SetLastError(ISS_SOCKET_CREATE, _T(__FUNCTION__), ::WSAGetLastError());

	return isOK;
}
void versionManager::getMainModuleVersion(VMMAPDEF& mapVersion)
{
	std::string   strVersion = "";
	TCHAR szBankPath[1000];

	_tcscpy_s(szBankPath, getModulePath().c_str());
	_tcscat_s(szBankPath, _T("\\MoneyHub.exe"));

	CFileVersionInfo vinfo;
	if (vinfo.Create(szBankPath))
	{
		tstring strFileVersion = vinfo.GetFileVersion();
		replace(strFileVersion.begin(), strFileVersion.end(), ',', '.');
		strFileVersion.erase(remove(strFileVersion.begin(), strFileVersion.end(), ' '), strFileVersion.end());
		strVersion = std::string(CT2A(strFileVersion.c_str(), 936));
	}
	else 
		return ;

	USES_CONVERSION;
	if(m_bEnName)
		mapVersion.insert(std::make_pair(L"Main",A2W(strVersion.c_str()) ) );
	else
	{
	    VMMAPDEF::iterator it = m_mapEnChName.find(L"Main");
		if( it != m_mapEnChName.end() )
			mapVersion.insert(std::make_pair(it->second.c_str(), A2W(strVersion.c_str()) ) );
	}
}
Esempio n. 20
0
CClientDlg::CClientDlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(CClientDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	VERIFY(g_CookieMgr.LoadFromFile(CT2A(g_lpszDefaultCookieFile), FALSE) || ::GetLastError() == ERROR_FILE_NOT_FOUND);
}
Esempio n. 21
0
HRESULT CPixelShaderCompiler::CompileShaderFromFile(
    LPCTSTR pSrcFile,
    LPCSTR pEntrypoint,
    LPCSTR pProfile,
    DWORD Flags,
    IDirect3DPixelShader9** ppPixelShader,
    CString* pDisasm,
    CString* pErrMsg)
{
    HRESULT ret = E_FAIL;
    if (FILE* fp = _tfsopen(pSrcFile, _T("rb"), _SH_SECURE)) {
        VERIFY(fseek(fp, 0, SEEK_END) == 0);
        long size = ftell(fp);
        rewind(fp);
        if (size > 0) {
            auto data = new(std::nothrow) char[(size_t)size];
            if (data) {
                if (fread(data, size, 1, fp) == 1) {
                    ret = InternalCompile(data, (size_t)size, CT2A(pSrcFile), pEntrypoint,
                                          pProfile, Flags, ppPixelShader, pDisasm, pErrMsg);
                } else {
                    ASSERT(FALSE);
                }
                delete[] data;
            } else {
                ASSERT(FALSE);
            }
        }
        VERIFY(fclose(fp) == 0);
    }
    return ret;
}
Esempio n. 22
0
//Called when selection inside the combobox has changed
void CEntityDialogClassInfo::OnCbnSelchangeCbClass()
{
	m_lbKey.ResetContent();

	//Get current selected class name
	std::string classname;
	CString selection;
	int sel = m_cbClass.GetCurSel();
	if( sel == CB_ERR )
		return;
	m_cbClass.GetLBText( m_cbClass.GetCurSel(), selection );
	classname = CT2A(selection);


	CEntityRegisterEntity *pEnt = GetEntityRegister()->GetEntity(classname);
	if( !pEnt )
		return;

	for( int i = 0; i < pEnt->size(); i++ )
	{
		m_lbKey.AddString( CA2T( pEnt->Get(i)->name.c_str() ) );
	}

	//select first index in key list
	m_lbKey.SetCurSel(0);
	OnLbnSelchangeListKey();
}
Esempio n. 23
0
void MainWindow::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	CString fileName;
	CFileDialog dlg(FALSE, //TRUE为OPEN对话框,FALSE为SAVE AS对话框
		NULL, 
		NULL,
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		(LPCTSTR)_TEXT("Excel Files (*.xls;*.xlsx)|*.xls;*.xlsx||"),
		NULL);
	if(dlg.DoModal()==IDOK)
	{
		fileName=dlg.GetPathName(); //文件名保存在了FilePathName里
		string filePath = CT2A(fileName.GetBuffer());

		Course **courses;
		int size;
		CourseManager* courseManager = CourseManager::getInstance();
		ExcelUtil* excelUtil = ExcelUtil::getInstance();
		courseManager->getCourses(courses, size);

		int courseTime;
		for (int i=0; i<size; i++)
		{
			courseTime = courses[i]->getCourseTime();
			
		}

		excelUtil->saveCoursesToFile(filePath, courses, size);
	}
	else
	{
		return;
	}
}
Esempio n. 24
0
ARCRESULT CArchiverUNACE::TestArchive(LPCTSTR ArcFileName,CString &strLog)
{
	TRACE(_T("TestArchive() called.\n"));
	ASSERT(IsOK());
	if(!IsOK()){
		return TEST_ERROR;
	}

	//tコマンドによるテストが実装されている
	CString Param=
		_T("t ")			//テスト
		_T("\"")
	;
	Param+=ArcFileName;
	Param+=_T("\"");

	std::vector<char> szLog(LOG_BUFFER_SIZE);
	szLog[0]='\0';
	int Ret=ArchiveHandler(NULL,CT2A(Param),&szLog[0],LOG_BUFFER_SIZE-1);
	strLog=&szLog[0];

	if(0==Ret){
		strLog+=_T("\r\n");
		strLog+=CString(MAKEINTRESOURCE(IDS_TESTARCHIVE_RESULT_OK));
		return TEST_OK;
	}
	else return TEST_NG;
}
Esempio n. 25
0
	void CPlugin::SetFirefoxCookie(const CString& strURL, const CString& strCookieHeader, ULONG_PTR ulWindowId)
	{
		CString strEventType = _T("IESetCookie");
		CString strDetail;
		Json::Value json;
		json["url"] = (LPCSTR)CT2A(strURL, CP_UTF8);
		json["header"] = (LPCSTR)CT2A(strCookieHeader, CP_UTF8);
		if (ulWindowId)
		{
			char szWindowId[32] = { 0 };
			_ui64toa_s(ulWindowId, szWindowId, 32, 10);
			json["windowId"] = szWindowId;
		}
		strDetail = CA2T(json.toStyledString().c_str(), CP_UTF8);
		FireEvent(strEventType, strDetail);
	}
Esempio n. 26
0
void CPlayer::HKOpenFile()
{
	CString strError;

	NAME(PlayM4_SetFileEndMsg)(m_index, m_hRenderWnd, WM_FILE_END);

	//NAME(PlayM4_SetFileRefCallBack)(m_index, FileRefDone, (DWORD)this);

	//NAME(PlayM4_SetDecCallBackEx)(m_index, DecCBFun, NULL, 0);	

	char szFilename[MAX_PATH];
	strcpy(szFilename, CT2A((LPCTSTR)m_strPlayFileName));

	if(!NAME(PlayM4_OpenFile)(m_index, szFilename))
	{
		//m_strPlayFileName = _T("");
		//strError.Format(_T("Open file failed(%s)"), MyErrorToString(NAME(PlayM4_GetLastError)(m_index)));
		//MessageBox(m_hRenderWnd, strError, _T("Error"), MB_OK);
		throw 0;
	}

	m_dwMaxFileTime = NAME(PlayM4_GetFileTime)(m_index);
	if(!m_dwMaxFileTime)
	{
		m_dwMaxFileTime = 1;
	}

	m_dwDisplayHour		= m_dwMaxFileTime/3600;
	m_dwDisplayMinute   = (m_dwMaxFileTime % 3600) / 60;
	m_dwDisplaySecond   = m_dwMaxFileTime % 60;
	m_dwTotalFrames		= NAME(PlayM4_GetFileTotalFrames)(m_index);

	Play();
}
void DebugLogger::Upgrade(LPCTSTR toVersion, int result) {
  #pragma pack(push)
  #pragma pack(1)
  struct RecordData {
    int             result;
    char            toVersion[24];    
  };
  #pragma pack(pop)

  // 根据可变配置文件中的配置项决定是否上传数据 lux
  VariableConfigBlock *config = WorkingParameters::GetInstance()->GetCurrentConfigParameters();
  int uploadLevel = config->GetIntParameter(_T("UploadLevel"), 1);
  if (uploadLevel == 0)
  {
	  return;
  }
  if (logFile_.m_hFile == INVALID_HANDLE_VALUE) {
	  return;
  }

  if (IsUploadDetail(uploadLevel, result))
  {
	  RecordData data;
	  ZeroMemory(&data, sizeof(data));
	  strncpy(data.toVersion, CT2A(toVersion, CP_UTF8), _countof(data.toVersion));
	  data.result = result;

	  WriteRecord("UPG ", &data, sizeof(data));
  }
  else
  {
	  WriteRecord("UPG ", &result, sizeof(result));
  }
}
Esempio n. 28
0
BOOL IEHistoryLog::GetLog( Json::Value &log_value )
{
    CComPtr<IUrlHistoryStg2> history;
    CComPtr<IEnumSTATURL> enum_staturl;
    STATURL url = {0};
    url.cbSize = sizeof(url);

    std::map<CString, int> url_map;

    if(FAILED(CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2, (void**)&history))) {
        return FALSE;
    }

    if(FAILED(history->EnumUrls(&enum_staturl))) {
        return FALSE;
    }

    enum_staturl->Reset();
    CString url_str;
    ULONG fetched = 0;
    while(SUCCEEDED(enum_staturl->Next(1, &url, &fetched))) {
        if(fetched == 0) {
            break;
        }
        
        if (url.pwcsUrl) {
            if (_wcsnicmp(url.pwcsUrl, L"http", 4) == 0) {
                URL_COMPONENTS url_component = {0};
                url_component.dwStructSize = sizeof(url_component);
                TCHAR host_name[INTERNET_MAX_HOST_NAME_LENGTH] = {0};
                url_component.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH;
                url_component.lpszHostName = host_name;
                InternetCrackUrl(url.pwcsUrl, wcslen(url.pwcsUrl), ICU_DECODE, &url_component);
                _tcslwr_s(host_name);
                url_map[host_name]++;
            }
        }
        
        if (url.pwcsTitle) {
            CoTaskMemFree(url.pwcsTitle);
            url.pwcsTitle = NULL;
        }

        if (url.pwcsUrl) {
            CoTaskMemFree(url.pwcsUrl);
            url.pwcsUrl = NULL;
        }
    }

    for (std::map<CString, int>::iterator it = url_map.begin();
        it != url_map.end(); ++it) {
            Json::Value item;
            item["host_name"] = CT2A(it->first.GetString()).m_psz;
            item["count"] = it->second;
            log_value.append(item);
    }

    return TRUE;
}
Esempio n. 29
0
BOOL sockaddr_A_2_IN(ADDRESS_FAMILY usFamily, LPCTSTR pszAddress, USHORT usPort, SOCKADDR_IN& addr)
{
	addr.sin_family			= usFamily;
	addr.sin_port			= htons(usPort);
	addr.sin_addr.s_addr	= inet_addr(CT2A(pszAddress));

	return addr.sin_addr.s_addr != INADDR_NONE;
}
Esempio n. 30
0
bool TcpSocket::Listen(LPCTSTR address, int port) {
  sockaddr_in addr;
  addr.sin_family = AF_INET;
  addr.sin_addr.S_un.S_addr = inet_addr(CT2A(address));
  addr.sin_port = htons(port);

  return Listen((const sockaddr *)&addr, sizeof(addr));
}