当前位置: 首页>>代码示例>>C++>>正文


C++ tstring::c_str方法代码示例

本文整理汇总了C++中tstring::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::c_str方法的具体用法?C++ tstring::c_str怎么用?C++ tstring::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tstring的用法示例。


在下文中一共展示了tstring::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

CAddressBar::CBnt::CBnt(int64 ID,tstring text)
			:ButtonItem(ID,text.c_str(),NULL,false)
{
	
};
开发者ID:GMIS,项目名称:GMIS,代码行数:5,代码来源:AddressBar.cpp

示例2: Execute

int Helium::Execute( const tstring& command, tstring& output, bool showWindow )
{
    HANDLE hReadPipe;
    HANDLE hWritePipe;
    SECURITY_ATTRIBUTES sa;
    sa.nLength              = sizeof(sa);
    sa.lpSecurityDescriptor = NULL;
    sa.bInheritHandle       = TRUE;
    if( !CreatePipe( &hReadPipe, &hWritePipe, &sa, 0 ) )
    {
        return -1;
    }

    STARTUPINFO          si;
    memset( &si, 0, sizeof(si) );
    si.cb          = sizeof(si);
    si.dwFlags     = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
    si.wShowWindow = static_cast<int>( showWindow );
    si.hStdOutput  = hWritePipe;
    si.hStdError   = hWritePipe;      

    PROCESS_INFORMATION  pi;
    memset( &pi, 0, sizeof( pi ) );

    if( !CreateProcess(
        NULL,                                                 // filename
        (tchar_t*) command.c_str(),                           // command line for child
        NULL,                                                 // process security descriptor
        NULL,                                                 // thread security descriptor
        TRUE,                                                 // inherit handles?
        showWindow ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW,   // creation flags
        NULL,                                                 // inherited environment address
        NULL,                                                 // startup dir; NULL = start in current
        &si,                                                  // pointer to startup info (input)
        &pi ) )                                               // pointer to process info (output)
    {
        ::CloseHandle( hReadPipe );
        ::CloseHandle( hWritePipe );
        return -1;
    }

    // close the write end of the pipe so the child will terminate it with EOF
    ::CloseHandle( hWritePipe );

    // read from the pipe until EOF condition reached
    tchar_t buffer[80];
    unsigned long count;
    tstringstream stream;
    BOOL success = TRUE;
    do
    {
        while ( success = ReadFile( hReadPipe, buffer, sizeof(buffer), &count, NULL ) )
        {
            if( success )
            {
                stream.write( buffer, count );
            }
            else
            {
                if ( ::GetLastError() == ERROR_BROKEN_PIPE )
                {
                    break;
                }
                else
                {
                    return -1;
                }
            }
        }
    } while( success && count );

    // done reading, close our read pipe
    ::CloseHandle( hReadPipe );

    // copy output string
    output = stream.str();

    // get exit code
    DWORD result = 0;
    BOOL codeResult = ::GetExitCodeProcess( pi.hProcess, &result );
    HELIUM_ASSERT( codeResult );

    // close the process handle
    ::CloseHandle( pi.hProcess );
    ::CloseHandle( pi.hThread );

    return result;
}
开发者ID:,项目名称:,代码行数:88,代码来源:

示例3: GetName

 gcc_pure
 tstring::const_pointer GetName() const {
   return task_name.c_str();
 }
开发者ID:Adrien81,项目名称:XCSoar,代码行数:4,代码来源:TaskStore.hpp

示例4: WriteContactRate

void CQuotesProviderBase::WriteContactRate(MCONTACT hContact,double dRate,const tstring& rsSymbol/* = ""*/)
{
	time_t nTime = ::time(NULL);

	if(false == rsSymbol.empty())
	{
		db_set_ts(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_SYMBOL,rsSymbol.c_str());
	}

	double dPrev = 0.0;
	bool bValidPrev = Quotes_DBReadDouble(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_CURR_VALUE,dPrev);
	if(true == bValidPrev)
	{
		Quotes_DBWriteDouble(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_PREV_VALUE,dPrev);
	}

	Quotes_DBWriteDouble(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_CURR_VALUE,dRate);
	db_set_dw(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_FETCH_TIME,nTime);

	tstring sSymbol = rsSymbol;

	tostringstream oNick;
	oNick.imbue(GetSystemLocale());
	if(false == m_sContactListFormat.empty())
	{
		tstring s = format_rate(this,hContact,m_sContactListFormat,dRate);
		oNick << s;
	}
	else
	{
		if(true == sSymbol.empty())
		{
			sSymbol = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_SYMBOL);
		}
		oNick << std::setfill(_T(' ')) << std::setw(10) << std::left << sSymbol << std::setw(6) << std::right << dRate;
	}
	CTendency tendency;

	if (true == tendency.Parse(this, m_sTendencyFormat, hContact))
		do_set_contact_extra_icon(hContact, tendency);

	db_set_ts(hContact,LIST_MODULE_NAME,CONTACT_LIST_NAME,oNick.str().c_str());

	tstring sStatusMsg = format_rate(this,hContact,m_sStatusMsgFormat,dRate);
	if(false == sStatusMsg.empty())
	{
		db_set_ts(hContact,LIST_MODULE_NAME,STATUS_MSG_NAME,sStatusMsg.c_str());
	}
	else
	{
		db_unset(hContact,LIST_MODULE_NAME,STATUS_MSG_NAME);
	}

	bool bUseContactSpecific = (db_get_b(hContact,QUOTES_PROTOCOL_NAME,DB_STR_CONTACT_SPEC_SETTINGS,0) > 0);

	CAdvProviderSettings global_settings(this);

	WORD dwMode = (bUseContactSpecific) 
		? db_get_w(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG,static_cast<WORD>(lmDisabled))
		: global_settings.GetLogMode();
	if(dwMode&lmExternalFile)
	{
		bool bAdd = true;
		bool bOnlyIfChanged = (bUseContactSpecific)
			? (db_get_w(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG_FILE_CONDITION,1) > 0)
			: global_settings.GetLogOnlyChangedFlag();
		if(true == bOnlyIfChanged)
		{
			bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate,dPrev)));
		}
		if(true == bAdd)
		{
			tstring sLogFileName =  (bUseContactSpecific)
				? Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG_FILE,global_settings.GetLogFileName().c_str())
				: global_settings.GetLogFileName();

			if(true == sSymbol.empty())
			{
				sSymbol = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_SYMBOL);
			}

			sLogFileName = GenerateLogFileName(sLogFileName,sSymbol);

			tstring sFormat = global_settings.GetLogFormat();
			if(bUseContactSpecific)
			{
				CQuotesProviderVisitorDbSettings visitor;
				Accept(visitor);
				sFormat = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_FORMAT_LOG_FILE,visitor.m_pszDefLogFileFormat);
			}

			log_to_file(this,hContact,dRate,sLogFileName,sFormat);
		}
	}
	if(dwMode&lmInternalHistory)
	{
		bool bAdd = true;
		bool bOnlyIfChanged = (bUseContactSpecific) 
			? (db_get_w(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_HISTORY_CONDITION,1) > 0)
			: global_settings.GetHistoryOnlyChangedFlag();
//.........这里部分代码省略.........
开发者ID:slotwin,项目名称:miranda-ng,代码行数:101,代码来源:QuotesProviderBase.cpp

示例5: addSummaryMenu

// !SMT!-UI
void UserInfoSimple::addSummaryMenu()
{
	// TODO: move obtain information about the user in the UserManager
	if (!getUser())
		return;
		
	CWaitCursor l_cursor_wait; //-V808
	
	UserInfoGuiTraits::userSummaryMenu.InsertSeparatorLast(getUser()->getLastNickT());
	
	ClientManager::UserParams l_params;
	if (ClientManager::getUserParams(getUser(), l_params))
	{
		tstring userInfo = TSTRING(SLOTS) + _T(": ") + Util::toStringW(l_params.m_slots) + _T(", ") + TSTRING(SHARED) + _T(": ") + Util::formatBytesW(l_params.m_bytesShared);
		
		if (l_params.m_limit)
		{
			userInfo += _T(", ") + TSTRING(SPEED_LIMIT) + _T(": ") + Util::formatBytesW(l_params.m_limit) + _T('/') + WSTRING(SEC);
		}
		
		UserInfoGuiTraits::userSummaryMenu.AppendMenu(MF_STRING | MF_DISABLED, IDC_NONE, userInfo.c_str());
		
		const time_t slot = UploadManager::getReservedSlotTime(getUser());
		if (slot)
		{
			const tstring note = TSTRING(EXTRA_SLOT_TIMEOUT) + _T(": ") + Util::formatSecondsW((slot - GET_TICK()) / 1000);
			UserInfoGuiTraits::userSummaryMenu.AppendMenu(MF_STRING | MF_DISABLED, IDC_NONE, note.c_str());
		}
		
		if (!l_params.m_ip.empty())
		{
			UserInfoGuiTraits::userSummaryMenu.AppendMenu(MF_STRING | MF_DISABLED, IDC_NONE, l_params.getTagIP().c_str());
			
			const Util::CustomNetworkIndex l_location = Util::getIpCountry(l_params.m_ip, true); // Не обращаемся в базу данных
			const tstring loc = TSTRING(COUNTRY) + _T(": ") + l_location.getCountry() + _T(", ") + l_location.getDescription();
			UserInfoGuiTraits::userSummaryMenu.AppendMenu(MF_STRING | MF_DISABLED, IDC_NONE, loc.c_str());
			
			HubFrame::addDupeUsersToSummaryMenu(l_params);
		}
		else
		{
			UserInfoGuiTraits::userSummaryMenu.AppendMenu(MF_STRING | MF_DISABLED, IDC_NONE, l_params.getTagIP().c_str());
			HubFrame::addDupeUsersToSummaryMenu(l_params);
		}
	}
	
	//UserInfoGuiTraits::userSummaryMenu.AppendMenu(MF_SEPARATOR);
	
	bool caption = false;
	{
		UploadManager::LockInstanceQueue lockedInstance;
		const auto& users = lockedInstance->getUploadQueueL();
		for (auto uit = users.cbegin(); uit != users.cend(); ++uit)
		{
			if (uit->getUser() == getUser())
			{
				uint8_t l_count_menu = 0; // [+]PPA
				for (auto i = uit->m_waiting_files.cbegin(); i != uit->m_waiting_files.cend(); ++i)
				{
					if (!caption)
					{
						UserInfoGuiTraits::userSummaryMenu.InsertSeparatorLast(TSTRING(USER_WAIT_MENU));
						caption = true;
					}
					const tstring note =
					    _T('[') +
					    Util::toStringW((double)(*i)->getPos() * 100.0 / (double)(*i)->getSize()) +
					    _T("% ") +
					    Util::formatSecondsW(GET_TIME() - (*i)->getTime()) +
					    _T("]\t") +
					    Text::toT((*i)->getFile());
					UserInfoGuiTraits::userSummaryMenu.AppendMenu(MF_STRING | MF_DISABLED, IDC_NONE, note.c_str());
					if (l_count_menu++ == 10) //[+]PPA
					{
						UserInfoGuiTraits::userSummaryMenu.AppendMenu(MF_STRING | MF_DISABLED, IDC_NONE, _T("..."));
						break;
					}
				}
			}
		}
	}
	caption = false;
	{
		uint8_t l_count_menu = 0; // [+]PPA
		RLock(*QueueItem::g_cs);
		QueueManager::LockFileQueueShared l_fileQueue;
		const auto& downloads = l_fileQueue.getQueueL();
		for (auto j = downloads.cbegin(); j != downloads.cend(); ++j)
		{
			const QueueItemPtr& aQI = j->second;
			const bool src = aQI->isSourceL(getUser());
			bool badsrc = false;
			if (!src)
			{
				badsrc = aQI->isBadSourceL(getUser());
			}
			if (src || badsrc)
			{
				if (!caption)
//.........这里部分代码省略.........
开发者ID:craxycat,项目名称:flylinkdc-r5xx,代码行数:101,代码来源:UserInfoSimple.cpp

示例6: appendThis

void OMenu::appendThis(const tstring& aTitle, bool appendSeparator /*false*/) {
	dcassert(parent);
	parent->AppendMenu(MF_POPUP, (UINT_PTR)(HMENU)*this, aTitle.c_str());
	if (appendSeparator)
		InsertSeparatorFirst(aTitle);
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例7: addAllJreJvms

void WindowsRegistry::addAllJreJvms(vector<JVMInfo>* pVecJvmInfo, const tstring& regKey)
{
	try
	{
		LONG result;
		HKEY hKey;

		result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,regKey.c_str(),0,KEY_READ,&hKey);
		if (result != ERROR_SUCCESS)
		{
			// key may not exist so exit
			return;
		}

		TCHAR lpName[MAX_PATH];

		for (DWORD index = 0, result = ERROR_SUCCESS; result == ERROR_SUCCESS; index++) 
		{ 
			DWORD lpcName = MAX_PATH;
			result = RegEnumKeyEx(hKey, 
                     index, 
                     lpName, 
                     &lpcName, 
                     NULL, 
                     NULL, 
                     NULL, 
                     NULL); 

			if( result == ERROR_SUCCESS ) 
			{
				tstring dirName(lpName);	
				if( dirName.empty() )
				{
					continue;
				}

				tstring fullKeyPath = regKey + tstring(_T("\\")) + dirName;

				DEBUG_SHOW( tstring(_T("fullKeyPath=")) + fullKeyPath );
				tstring& javaHome = getStringValue(fullKeyPath, _T("JavaHome"));
				if( javaHome.empty() )
				{
					continue;
				}

				JVMInfo *pJvmInfo = new JVMInfo;
				pJvmInfo->setJavaBundle(Properties::JRE_JAVA_BUNDLE);
				pJvmInfo->setJavaHomePath(javaHome);
				pJvmInfo->setVersion(dirName);

				pVecJvmInfo->push_back(*pJvmInfo);
			}
		} 

		RegCloseKey(hKey);
	}
	catch(tstring& se)
	{
		ErrHandler::severeError( se );
	}
	catch(...)
	{
		DEBUG_SHOW( _T("Exception in WindowsRegistry.addAllJreJvms()") );
		ErrHandler::severeError( _T("Error getting JVM paths from registry.") );
	}
}
开发者ID:ValentinIUT,项目名称:JAVA,代码行数:66,代码来源:WindowsRegistry.cpp

示例8: Open

PMDModelPtr PMDFileLoader::Open( const tstring& filePath )
{
	m_fileName = filePath;

	TCHAR path[MAX_PATH];
	_tcscpy_s( path,MAX_PATH,filePath.c_str() );
	PathRemoveFileSpec( path );
	PathAddBackslash( path );
	m_path = path;

	FILE* fp=NULL;
	if( _tfopen_s(&fp,m_fileName.c_str(),_T("rb"))!=0 )
	{
		return PMDModelPtr();
	}

	fpos_t fsize = 0;
	fseek(fp,0,SEEK_END);
	fgetpos(fp,&fsize);

	fseek(fp,0,SEEK_SET); 

	size_t sz=(size_t)fsize;

	unsigned char* buffer=new unsigned char[sz];
	fread(buffer,1,sz,fp);

	fclose(fp);

	sPMD* pmd = new sPMD;
	bool ret = PMDLoad(buffer,sz,pmd);
	
	delete[] buffer;

	if( !ret )
	{
		delete pmd;
		return PMDModelPtr();
	}

	sPMD_Skin* skinBase = NULL;

	for( DWORD skinIdx=0;skinIdx<pmd->skin_list.skin_count;skinIdx++ )
	{
		sPMD_Skin* skin = &pmd->skin_list.skin[skinIdx];

		if( skin->skin_type == ePMD_SkinType_Base )
		{
			skinBase = skin;

			for( DWORD vertIdx = 0; vertIdx < skin->skin_vert_count ; vertIdx++ )
			{
				DWORD targetIndex = skin->skin_vert[vertIdx].index;
				memcpy( pmd->vertex_list.vertex[ targetIndex ].pos, skin->skin_vert[vertIdx].pos,sizeof(float)*3 );
			}
			
			break;
		}
	}

	for( DWORD skinIdx=0;skinIdx<pmd->skin_list.skin_count;skinIdx++ )
	{
		sPMD_Skin* skin = &pmd->skin_list.skin[skinIdx];

		if( skin->skin_type != ePMD_SkinType_Base )
		{
			for( DWORD vertIdx = 0; vertIdx < skin->skin_vert_count ; vertIdx++ )
			{
				DWORD targetIndex = skin->skin_vert[vertIdx].index;
				skin->skin_vert[vertIdx].index = skinBase->skin_vert[ targetIndex ].index;
			}
		}
	}

	Graphics* graphics = Graphics::GetInstance();

	sMaterial* pMaterials = new sMaterial[pmd->material_list.material_count];

	for( DWORD i=0;i<pmd->material_list.material_count;i++ )
	{
		sPMD_Material* pmdMat = &pmd->material_list.material[i];
		sMaterial* pMaterial = &pMaterials[i];

		pMaterial->colorDiffuse.r = 0.0f;
		pMaterial->colorDiffuse.g = 0.0f;
		pMaterial->colorDiffuse.b = 0.0f;
		pMaterial->colorDiffuse.a = pmdMat->alpha;

		pMaterial->colorAmbient.r = pmdMat->diffuse_color[0];
		pMaterial->colorAmbient.g = pmdMat->diffuse_color[1];
		pMaterial->colorAmbient.b = pmdMat->diffuse_color[2];
		pMaterial->colorAmbient.a = 0.0f;

		pMaterial->colorSpecular.r = pmdMat->specular_color[0];
		pMaterial->colorSpecular.g = pmdMat->specular_color[1];
		pMaterial->colorSpecular.b = pmdMat->specular_color[2];
		pMaterial->colorSpecular.a = 0.0f;

		pMaterial->colorEmissive.r = pmdMat->ambient_color[0];
		pMaterial->colorEmissive.g = pmdMat->ambient_color[1];
//.........这里部分代码省略.........
开发者ID:ZeusAFK,项目名称:MikuMikuGameEngine,代码行数:101,代码来源:PMDFileLoader.cpp

示例9: MakeMessage

tstring
TXOwl::MakeMessage(uint resId, const tstring& infoStr, TModule* module)
{
  return MakeMessage(resId, infoStr.c_str(), module);
}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:5,代码来源:except.cpp

示例10: cmd_run_as

bool cmd_run_as(const tstring& command,
                const RUN_AS_TYPE& as_type,
                const bool show_window /*= true*/)
{
    InfoLog("begin exec");

    bool execute_success = false;
    const unsigned short sw_flag = show_window ? SW_SHOWNORMAL : SW_HIDE;

    std::vector<HANDLE> processes;

    switch (as_type)
    {
    case AS_LOCAL:
        {
            DWORD created_pid = 0;
            HANDLE hProcess = ProcessCreator::create_process_in_local_context(command,
                created_pid, CREATE_NEW_CONSOLE, TSTR(""), sw_flag);
            if (hProcess)
            {
                InfoLog("create_process_in_local_context success, pid=%lu", created_pid);
                processes.push_back(hProcess);
            }
            else
            {
                ErrorLog("create_process_in_local_context fail");
            }
        }
        break;

    case AS_LOGON_USER:
    case AS_ALL_LOGON_USERS:
        {
            std::vector<DWORD> pids;
            find_pids_by_path(TSTR("explorer.exe"), pids);
            if (pids.empty())
            {
                ErrorLog("can not find any explorer.exe");
            }
            else
            {
                for (std::vector<DWORD>::const_iterator iter_pid = pids.begin();
                    iter_pid != pids.end();
                    ++iter_pid)
                {
                    InfoLog("explorer.exe pid=%lu", *iter_pid);
                    DWORD created_pid = 0;
                    HANDLE hProcess = ProcessCreator::create_process_as_same_token(*iter_pid,
                        command, created_pid, CREATE_NEW_CONSOLE, TSTR(""), sw_flag);
                    if (hProcess)
                    {
                        InfoLog("create_process_as_same_token success, pid=%lu", created_pid);
                        processes.push_back(hProcess);
                        if (as_type == AS_LOGON_USER)
                        {
                            break;
                        }
                    }
                    else
                    {
                        ErrorLog(TSTR("create_process_as_same_token fail, pid=%lu, cmd=[%s]"),
                            *iter_pid, command.c_str());
                    }
                }
            }

            if (processes.empty())
            {
                ErrorLog("no new process in user context was created");
            }
        }
        break;

    default:
        ErrorLog("unknown run_as type: %d", as_type);
        break;
    }

    if (!processes.empty())
    {
        //最多伺候3秒,不必看结果,让守护进程去看
        WaitForMultipleObjects(processes.size(), &processes[0], TRUE, 3 * 1000);
        for (std::vector<HANDLE>::iterator iter_process = processes.begin();
            iter_process != processes.end();
            ++iter_process)
        {
            CloseHandle(*iter_process);
            *iter_process = NULL;
        }

        execute_success = true;
    }
    else
    {
        execute_success = false;
    }

    InfoLog("end exec with %s", execute_success ? "success" : "fail");
    return execute_success;
}
开发者ID:839687571,项目名称:DaemonSvc,代码行数:100,代码来源:cmd_run_as.cpp

示例11: ProjectFile

inline ProjectFile::ProjectFile(const tstring& pathName)
	: m_pathName(pathName)
	, m_fileName(CPath(pathName.c_str()).FileName())
	, m_xmlDoc()
{
}
开发者ID:chrisoldwood,项目名称:VCProjCompare,代码行数:6,代码来源:ProjectFile.hpp

示例12: GetComponentKeyFilename

/////////////////////////////////////////////////////////////////////
// 
// Function:    GetComponentKeyFilename
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT BOINCCABase::GetComponentKeyFilename( 
    const tstring strComponentName, 
    tstring&      strComponentKeyFilename
    )
{
    UINT        uiReturnValue = 0;
    tstring     strMessage;
    tstring     strQuery;
    TCHAR       szBuffer[256];
    DWORD       dwBufferSize = sizeof(szBuffer);
    MSIHANDLE   hDatabase;
    MSIHANDLE   hView;
    MSIHANDLE   hRecComponentName;
    MSIHANDLE   hRec;


	// Get the handle to the MSI package we are executing for.
	hDatabase = MsiGetActiveDatabase(m_hMSIHandle);
	if (!hDatabase) return ERROR_INSTALL_FAILURE;

	// Construct the query that is going to give us the result we need.
    strQuery  = _T("SELECT `KeyPath` FROM `Component` WHERE `Component`= ?");

	// Create the view
    uiReturnValue = MsiDatabaseOpenView(hDatabase, strQuery.c_str(), &hView);
    switch(uiReturnValue)
    {
    case ERROR_BAD_QUERY_SYNTAX:
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiDatabaseOpenView reports an invalid query was issued")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    case ERROR_INVALID_HANDLE:
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiDatabaseOpenView reports an invalid handle was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    }

    // Create query parameter
    hRecComponentName = MsiCreateRecord(1);
    uiReturnValue = MsiRecordSetString(hRecComponentName, 1, strComponentName.c_str());
    switch(uiReturnValue)
    {
    case ERROR_INVALID_HANDLE:
        MsiCloseHandle(hRecComponentName);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiRecordSetString reports an invalid handle was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    case ERROR_INVALID_PARAMETER:
        MsiCloseHandle(hRecComponentName);
        MsiCloseHandle(hDatabase);

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            _T("MsiRecordSetString reports an invalid parameter was used")
        );

        return ERROR_INSTALL_FAILURE;
        break;
    }
//.........这里部分代码省略.........
开发者ID:Ashod,项目名称:Boinc,代码行数:101,代码来源:boinccas.cpp

示例13: GetProperty

/////////////////////////////////////////////////////////////////////
// 
// Function:    GetProperty
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT BOINCCABase::GetProperty( 
    const tstring strPropertyName, 
    tstring&      strPropertyValue,
    bool          bDisplayValue
    )
{
    LPTSTR  lpszBuffer = NULL;
    DWORD   dwCharacterCount = 0;
    tstring strMessage;
    UINT    uiReturnValue = 0;

    uiReturnValue = MsiGetProperty(m_hMSIHandle, strPropertyName.c_str(), _T(""), &dwCharacterCount);
    switch(uiReturnValue)
    {
    case ERROR_INVALID_HANDLE:
    case ERROR_INVALID_PARAMETER:
        strMessage  = _T("Failed to get '") + strPropertyName;
        strMessage += _T("'");

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            strMessage.c_str()
        );
        return ERROR_INSTALL_FAILURE;
        break;
    }

    // Allocate memory for the property value return buffer
    lpszBuffer = (LPTSTR) malloc( ((++dwCharacterCount)*sizeof(LPTSTR)) );
    uiReturnValue = MsiGetProperty(m_hMSIHandle, strPropertyName.c_str(), lpszBuffer, &dwCharacterCount);
    switch(uiReturnValue)
    {
    case ERROR_INVALID_HANDLE:
    case ERROR_INVALID_PARAMETER:
        strMessage  = _T("Failed to get '") + strPropertyName;
        strMessage += _T("' after allocating the buffer");

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            strMessage.c_str()
        );
        if ( lpszBuffer ) free( lpszBuffer );
        return ERROR_INSTALL_FAILURE;
        break;
    }

    strPropertyValue = lpszBuffer;
    free( lpszBuffer );

    strMessage  = _T("Successfully retrieved '") + strPropertyName;
    strMessage += _T("' with a value of '");
    if (bDisplayValue)
        strMessage += strPropertyValue;
    else
        strMessage += _T("<Value Hidden>");
    strMessage += _T("'");

    LogMessage(
        INSTALLMESSAGE_INFO,
        NULL, 
        NULL,
        NULL,
        NULL,
        strMessage.c_str()
    );

    return ERROR_SUCCESS;
}
开发者ID:Ashod,项目名称:Boinc,代码行数:83,代码来源:boinccas.cpp

示例14: GetRegistryValue

/////////////////////////////////////////////////////////////////////
// 
// Function:    GetRegistryValue
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT BOINCCABase::GetRegistryValue( 
    const tstring strName, 
    tstring&      strValue,
    bool          bDisplayValue
    )
{
	LONG lReturnValue;
	HKEY hkSetupHive;
	DWORD dwSize = 0;
    LPTSTR lpszRegistryValue = NULL;
    tstring strMessage;

	lReturnValue = RegOpenKeyEx(
        HKEY_LOCAL_MACHINE, 
        _T("SOFTWARE\\Space Sciences Laboratory, U.C. Berkeley\\BOINC Setup"),  
		0, 
        KEY_READ,
        &hkSetupHive
    );
	if (lReturnValue != ERROR_SUCCESS) return ERROR_INSTALL_FAILURE;

    // How large does our buffer need to be?
    RegQueryValueEx(
        hkSetupHive,
        strName.c_str(),
        NULL,
        NULL,
        NULL,
        &dwSize
    );

    // Allocate the buffer space.
    lpszRegistryValue = (LPTSTR) malloc(dwSize);
    (*lpszRegistryValue) = NULL;

    // Now get the data
    lReturnValue = RegQueryValueEx( 
        hkSetupHive,
        strName.c_str(),
        NULL,
        NULL,
        (LPBYTE)lpszRegistryValue,
        &dwSize
    );

    // Send up the returned value.
    if (lReturnValue == ERROR_SUCCESS) strValue = lpszRegistryValue;

    // Cleanup
	RegCloseKey(hkSetupHive);
    free(lpszRegistryValue);

    // One last check to make sure everything is on the up and up.
    if (lReturnValue != ERROR_SUCCESS) return ERROR_INSTALL_FAILURE;


    strMessage  = _T("Successfully retrieved registry value '") + strName;
    strMessage += _T("' with a value of '");
    if (bDisplayValue)
        strMessage += strValue;
    else
        strMessage += _T("<Value Hidden>");
    strMessage += _T("'");

    LogMessage(
        INSTALLMESSAGE_INFO,
        NULL, 
        NULL,
        NULL,
        NULL,
        strMessage.c_str()
    );

    return ERROR_SUCCESS;
}
开发者ID:Ashod,项目名称:Boinc,代码行数:82,代码来源:boinccas.cpp

示例15: Load

bool CPicture::Load(tstring sFilePathName)
{
	bool bResult = false;
	bIsIcon = false;
	lpIcons = nullptr;
	//CFile PictureFile;
	//CFileException e;
	FreePictureData(); // Important - Avoid Leaks...

	// No-op if no file specified
	if (sFilePathName.empty())
		return true;

	// Load & initialize the GDI+ library if available
	HMODULE hGdiPlusLib = AtlLoadSystemLibraryUsingFullPath(L"gdiplus.dll");
	if (hGdiPlusLib && GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr) == Ok)
	{
		bHaveGDIPlus = true;
	}
	// Since we loaded the gdiplus.dll only to check if it's available, we
	// can safely free the library here again - GdiplusStartup() loaded it too
	// and reference counting will make sure that it stays loaded until GdiplusShutdown()
	// is called.
	FreeLibrary(hGdiPlusLib);

	// Attempt to load using GDI+ if available
	if (bHaveGDIPlus)
	{
		pBitmap = new Bitmap(sFilePathName.c_str(), FALSE);
		GUID guid;
		pBitmap->GetRawFormat(&guid);

		if (pBitmap->GetLastStatus() != Ok)
		{
			delete pBitmap;
			pBitmap = nullptr;
		}

		// gdiplus only loads the first icon found in an icon file
		// so we have to handle icon files ourselves :(

		// Even though gdiplus can load icons, it can't load the new
		// icons from Vista - in Vista, the icon format changed slightly.
		// But the LoadIcon/LoadImage API still can load those icons,
		// at least those dimensions which are also used on pre-Vista
		// systems.
		// For that reason, we don't rely on gdiplus telling us if
		// the image format is "icon" or not, we also check the
		// file extension for ".ico".
		auto lowerfilename = sFilePathName;
		std::transform(lowerfilename.begin(), lowerfilename.end(), lowerfilename.begin(), ::tolower);
		bIsIcon = (guid == ImageFormatIcon) || (wcsstr(lowerfilename.c_str(), L".ico")) || (wcsstr(lowerfilename.c_str(), L".cur"));
		bIsTiff = (guid == ImageFormatTIFF) || (wcsstr(lowerfilename.c_str(), L".tiff"));
		m_Name = sFilePathName;

		if (bIsIcon)
		{
			// Icon file, get special treatment...
			if (pBitmap)
			{
				// Cleanup first...
				delete (pBitmap);
				pBitmap = nullptr;
				bIsIcon = true;
			}

			CAutoFile hFile = CreateFile(sFilePathName.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
			if (hFile)
			{
				BY_HANDLE_FILE_INFORMATION fileinfo;
				if (GetFileInformationByHandle(hFile, &fileinfo))
				{
					lpIcons = new BYTE[fileinfo.nFileSizeLow];
					DWORD readbytes;
					if (ReadFile(hFile, lpIcons, fileinfo.nFileSizeLow, &readbytes, nullptr))
					{
						// we have the icon. Now gather the information we need later
						if (readbytes >= sizeof(ICONDIR))
						{
							// we are going to open same file second time so we have to close the file now
							hFile.CloseHandle();

							LPICONDIR lpIconDir = (LPICONDIR)lpIcons;
							if ((lpIconDir->idCount) && ((lpIconDir->idCount * sizeof(ICONDIR)) <= fileinfo.nFileSizeLow))
							{
								try
								{
									bResult = false;
									nCurrentIcon = 0;
									hIcons = new HICON[lpIconDir->idCount];
									// check that the pointers point to data that we just loaded
									if (((BYTE*)lpIconDir->idEntries > (BYTE*)lpIconDir) && 
										(((BYTE*)lpIconDir->idEntries) + (lpIconDir->idCount * sizeof(ICONDIRENTRY)) < ((BYTE*)lpIconDir) + fileinfo.nFileSizeLow))
									{
										m_Width = lpIconDir->idEntries[0].bWidth == 0 ? 256 : lpIconDir->idEntries[0].bWidth;
										m_Height = lpIconDir->idEntries[0].bHeight == 0 ? 256 : lpIconDir->idEntries[0].bHeight;
										bResult = true;
										for (int i=0; i<lpIconDir->idCount; ++i)
										{
											hIcons[i] = (HICON)LoadImage(nullptr, sFilePathName.c_str(), IMAGE_ICON,
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的tstring::c_str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。