コード例 #1
1
bool OfflineDataStore::GetRegKeyForDocNum(const CStdString& sDocID, CRegKey& rkResult) 
{
	CStdString sNoVersionDocID = RemoveVersionLabel(sDocID);
	sNoVersionDocID.MakeLower();

	CRegKey rk;
	long lResult = rk.Open(HKEY_CURRENT_USER, GetRegistryKeyName());

	DWORD dwIndex = 0;
	while(lResult == ERROR_SUCCESS)
	{
		CStdString sResult;
		DWORD dwLength = MAX_PATH;
		lResult = rk.EnumKey(dwIndex, sResult.GetBuffer(MAX_PATH), &dwLength);
		sResult.ReleaseBuffer();
		sResult.MakeLower();

		dwIndex++;
		if(sResult.Find(sNoVersionDocID) != -1)
		{
			return (rkResult.Open(HKEY_CURRENT_USER, GetKeyNameForDocID(sResult)) == ERROR_SUCCESS);
		}
	}
	return false;
}
コード例 #2
0
ファイル: PathReadWriter.cpp プロジェクト: killbug2004/WSProf
void PathReadWriter::GetPathList(const CStdString& sPathList, std::vector<CStdString>& pathList)
{
	pathList.clear();
	pathList.reserve(std::count(sPathList.begin(), sPathList.end(), _T(';')) + 1);

	int nStartPos = 0;
	for (int nEndPos = (int) sPathList.find(_T(';'));
		nEndPos >= 0;
		nEndPos = (int) sPathList.find(_T(';'), nStartPos = nEndPos + 1))
	{
		CStdString sSubPath = sPathList.Mid(nStartPos, nEndPos - nStartPos).Trim();
		if (!sSubPath.IsEmpty())
		{
			::PathRemoveBackslash(sSubPath.GetBuffer(MAX_PATH));
			sSubPath.ReleaseBuffer();
			pathList.push_back(sSubPath);
		}
	}
	CStdString sSubPath = sPathList.Mid(nStartPos).Trim();
	if (!sSubPath.IsEmpty())
	{
		::PathRemoveBackslash(sSubPath.GetBuffer(MAX_PATH));
		sSubPath.ReleaseBuffer();
		pathList.push_back(sSubPath);
	}
}
コード例 #3
0
CStdString NetworkDriveHelper::MapNetworkDrive()
{
	NETRESOURCE nr;
	CStdString sDisk	= GetUnusedDiskName();
	TCHAR* pDisk		= sDisk.GetBuffer();

	CStdString sPath	= GetUNCShareName();
	TCHAR* pPath		= sPath.GetBuffer();

	nr.dwScope			= RESOURCE_CONNECTED;  
	nr.dwType			= RESOURCETYPE_DISK;  
	nr.dwDisplayType	= RESOURCEDISPLAYTYPE_GENERIC; 
	nr.dwUsage			= RESOURCEUSAGE_CONNECTABLE;  
	nr.lpLocalName		= pDisk;  
	nr.lpRemoteName		= pPath;  
	nr.lpComment		= _T("Mapped network drive for Workshare LFS Testing");  
	nr.lpProvider		= NULL;

	DWORD dwErr			= WNetAddConnection2(&nr, NULL, NULL, 0);

	sDisk.ReleaseBuffer();
	sPath.ReleaseBuffer();
	if (dwErr == NO_ERROR || dwErr == ERROR_ALREADY_ASSIGNED)
		return pDisk;

	return _T("");
}
コード例 #4
0
ファイル: TestUtils.cpp プロジェクト: killbug2004/WSProf
CStdString CTestUtils::GetTrunkPath()
{
	CStdString sModuleName;
	CStdString sLongModuleName;

	HMODULE hMod = GetModuleHandle(L"testrunner.dll");
	GetModuleFileName(hMod, sModuleName.GetBuffer(MAX_PATH), MAX_PATH);
	sModuleName.ReleaseBuffer();

	DWORD dRet = GetLongPathName(sModuleName, sLongModuleName.GetBuffer(MAX_PATH), MAX_PATH);
	sLongModuleName.ReleaseBuffer();
	if (dRet == 0)
	{
		sLongModuleName = sModuleName;
	}

	sModuleName = sLongModuleName;
	sModuleName.ToLower();

	if ((sModuleName.Find(ARCHDIR +  _T( "\\debug\\")) != -1) ||
		(sModuleName.Find(ARCHDIR + _T( "\\release\\")) != -1))
	{
		return PathBefore(sModuleName, ARCHDIR );
	}

	// This won't work for paths beyond the root without win32\\release but at least it doesn't crash
	// applications like deltaview when it is doing a regserver
	return PathBefore(sModuleName, "\\");
}
コード例 #5
0
ファイル: ImageCode.cpp プロジェクト: vizcount/work
bool CImageCode::GetImage(CStdString strURL, CStdString strLocFile)
{
	BOOL bRes = InternetGetFile(strURL.GetBuffer(), strLocFile.GetBuffer());
	if (bRes)
	{
		return true;
	}
	return false;
}
コード例 #6
0
ファイル: MarkupSTL.cpp プロジェクト: Avoidnf8/xbmc-fork
CStdString CMarkupSTL::x_TextToDoc( const char * szText, bool bAttrib ) const
{
	// Convert text as seen outside XML document to XML friendly
	// replacing special characters with ampersand escape codes
	// E.g. convert "6>7" to "6&gt;7"
	//
	// &lt;   less than
	// &amp;  ampersand
	// &gt;   greater than
	//
	// and for attributes:
	//
	// &apos; apostrophe or single quote
	// &quot; double quote
	//
	static _TCHAR* szaReplace[] = { _T("&lt;"),_T("&amp;"),_T("&gt;"),_T("&apos;"),_T("&quot;") };
	const _TCHAR* pFind = bAttrib?_T("<&>\'\""):_T("<&>");
	CStdString csText;
	const _TCHAR* pSource = szText;
	int nDestSize = _tcslen(pSource);
	nDestSize += nDestSize / 10 + 7;
	_TCHAR* pDest = csText.GetBuffer(nDestSize);
	int nLen = 0;
	_TCHAR cSource = *pSource;
	_TCHAR* pFound;
	while ( cSource )
	{
		if ( nLen > nDestSize - 6 )
		{
			csText.ReleaseBuffer(nLen);
			nDestSize *= 2;
			pDest = csText.GetBuffer(nDestSize);
		}
		if ( (pFound=_tcschr(pFind,cSource)) != NULL )
		{
			pFound = szaReplace[pFound-pFind];
			_tcscpy(&pDest[nLen],pFound);
			nLen += _tcslen(pFound);
		}
		else
		{
			_tccpy( &pDest[nLen], pSource );
			++nLen;
		}
		pSource += _tclen( pSource );
		cSource = *pSource;
	}
	csText.ReleaseBuffer(nLen);
	return csText;
}
コード例 #7
0
ファイル: WorkshareMenu.cpp プロジェクト: killbug2004/WSProf
CStdString CWorkshareMenu::GetSystemPath(LONG lPathClsid) const
{	
	typedef HRESULT (CALLBACK* PROC_SHGetFolderPath)(HWND, int, HANDLE, DWORD, LPTSTR);

	CStdString sPath = L"";
	bool bUsingOldDll = false;

	HMODULE hModShFolder = LoadLibrary(_T("shfolder.dll"));

	if (hModShFolder == NULL)
		return sPath;

	PROC_SHGetFolderPath proc = (PROC_SHGetFolderPath) GetProcAddress(hModShFolder, FOLDERPROCNAME);

	if (proc != NULL)
	{
		HRESULT hr = proc (NULL, lPathClsid, NULL, SHGFP_TYPE_CURRENT, sPath.GetBuffer(MAX_PATH));
		sPath.ReleaseBuffer();

		if (FAILED(hr))
		{
			CStdString sErr;
			sErr.Format(_T("Failed to get the system path (CSIDL): %d. Error: %d"), lPathClsid, hr);
			OutputDebugString(sErr.c_str());
		}
	}
	FreeLibrary(hModShFolder);

	return sPath; 
}
コード例 #8
0
ファイル: TestUtils.cpp プロジェクト: killbug2004/WSProf
CStdString CTestUtils::GetPath(int nFolder)
{
	CStdString sFolder;
	HRESULT hr = SHGetFolderPath(NULL, nFolder, NULL, SHGFP_TYPE_CURRENT, sFolder.GetBuffer(MAX_PATH));
	sFolder.ReleaseBuffer();
	return SUCCEEDED(hr) ? sFolder : _T("");
}
コード例 #9
0
CStdString SystemFolderInfo::GetProfilesDirectory()
{
	CStdString profileDirectory;

	HMODULE dllHandle = ::LoadLibrary(_T("userenv.dll"));
	if(dllHandle == NULL)
	{
		LOG_WS_ERROR(_T("Failed to load userenv.dll"));
		return profileDirectory;
	}

	PROC_GetProfilesDir proc = (PROC_GetProfilesDir)::GetProcAddress(dllHandle, PROFILESPROCNAME);
	if(NULL == proc)
	{
		LOG_WS_ERROR(_T("Failed to get function 'GetProfilesDirectory'"));
		::FreeLibrary(dllHandle);
		return profileDirectory;
	}

	DWORD size = _MAX_PATH;
	BOOL bSuccess = proc(profileDirectory.GetBuffer(MAX_PATH), &size);
	profileDirectory.ReleaseBuffer();

	if(!bSuccess)
		LOG_WS_ERROR(_T("Failed to call function 'GetProfilesDirectory'"));

	::FreeLibrary(dllHandle);

	return profileDirectory;
}
コード例 #10
0
bool OfflineDocIDResolver::GetOfflineDocumentInfo(const CStdString& sOnlineLibraryToSearch, const CStdString& sDocNum, CStdString& sOfflineDocNum, CStdString& sOfflineLibrary) const
{
    CRegKey key;
    if(key.Open(HKEY_CURRENT_USER, sOnlineLibraryToSearch) != ERROR_SUCCESS)
    {
        CStdString sErr = _T("Failed to Open Key : HKCU\\") + sOnlineLibraryToSearch;
        LOG_WS_ERROR(sErr.c_str());
        return false;
    }

    DWORD dwIndex = 0;
    DWORD dwLength =MAX_PATH;

    long lResult = ERROR_SUCCESS;
    while((lResult == ERROR_SUCCESS || lResult == ERROR_MORE_DATA))
    {
        DWORD dwLength =MAX_PATH;
        lResult = key.EnumKey(dwIndex , sOfflineLibrary.GetBuffer(MAX_PATH), &dwLength , NULL);
        sOfflineLibrary.ReleaseBuffer();
        if(lResult == ERROR_NO_MORE_ITEMS)
            return false;

        if(SearchOfflineLibrary(sOnlineLibraryToSearch + _T("\\") + sOfflineLibrary, sDocNum, sOfflineDocNum))
            return true;

        dwIndex++;
    }

    return false;
}
コード例 #11
0
CStdString ServerSettingsDialog::GetUsername() const
{
	CStdString sRetval;
	GetDlgItem(IDC_EDIT_USERNAME).GetWindowText( sRetval.GetBuffer(MAX_PATH), MAX_PATH );
	sRetval.ReleaseBuffer();
	return sRetval;
}
コード例 #12
0
CStdString ServerSettingsDialog::GetPassword() const
{
	CStdString sRetval;
	GetDlgItem(IDC_EDIT_PASSWORD).GetWindowText( sRetval.GetBuffer(MAX_PATH), MAX_PATH );
	sRetval.ReleaseBuffer();
	return sRetval;
}
コード例 #13
0
ファイル: DemoTestClass.cpp プロジェクト: killbug2004/WSProf
void TestWindowActivate::TestAttach()
{
	STARTUPINFO StartupInfo;
	PROCESS_INFORMATION ProcessInformation;
	ZeroMemory(&ProcessInformation, sizeof(PROCESS_INFORMATION));
	
	ZeroMemory(&StartupInfo, sizeof(STARTUPINFO));
	StartupInfo.cb = sizeof(STARTUPINFO);
	StartupInfo.wShowWindow = SW_SHOWNORMAL;
	StartupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
	
	assertMessage(!m_csWordPath.IsEmpty(),_T("Word path is empty - highly improbable state of affairs if you ask me"));
	CStdString sCommandLine = m_csWordPath + _T(" /W ");
	assertMessage(CreateProcess(NULL, sCommandLine.GetBuffer(), 0, 0, false, 0, 0, 0, &StartupInfo, &ProcessInformation) != 0,_T("Failed to create the Word process"));
	sCommandLine.ReleaseBuffer();

	CWSWindow win;
	win.Attach(ProcessInformation.dwProcessId);
	
	assertTest(win.GetWindowFromProcID());

	win.Activate();
	Sleep(1000);
	TerminateProcess(ProcessInformation.hProcess, 0);
}
コード例 #14
0
bool SharePointConnectRegistrar::RegisterItem()
{
	STARTUPINFO si;
	ZeroMemory( &si, sizeof(STARTUPINFO) );
	si.cb = sizeof( STARTUPINFO );

	PROCESS_INFORMATION pi;
	ZeroMemory( &pi, sizeof(PROCESS_INFORMATION) );

	CStdString sInstallDir = m_pProcessController->GetInstallDir();
	CStdString sAppName = L"WCRegisterConnectSettings.exe";
	CStdString sRegXml = L"Workshare.Connect.SharePoint.Registration.xml";
	CStdString sCmdLine = sInstallDir + L"\\"+ sAppName + L" \"" + sInstallDir + "\\" + sRegXml + L"\"";

	BOOL b = ::CreateProcess( NULL, sCmdLine.GetBuffer(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );
	sCmdLine.ReleaseBuffer();

	if( !b )
		return false;

	DWORD dwExitCode;
	::WaitForSingleObject( pi.hProcess, INFINITE );

	if( ::GetExitCodeProcess( pi.hProcess, &dwExitCode ) == 0 )	
	{
		::CloseHandle( pi.hProcess );
		::CloseHandle( pi.hThread );
		return false;;
	}

	::CloseHandle( pi.hProcess );
	::CloseHandle( pi.hThread );
	return true;
}
コード例 #15
0
ファイル: xData_item.cpp プロジェクト: Konnekt/kJabber
CStdString cXData::cItem_hwnd::GetValue () const {
	CStdString value;
	int size = GetWindowTextLength(hwnd);
	GetWindowText(hwnd, value.GetBuffer(size + 1), size + 1);
	value.ReleaseBuffer();
	return value;
}
コード例 #16
0
void COptionsDlgSelector::ValidateRenderingSetOptions()
{
	CStdString sOptionsFile;
	m_cboOptionsFile.GetWindowText(sOptionsFile.GetBuffer(MAX_PATH), MAX_PATH);
	sOptionsFile.ReleaseBuffer();
	if (m_bPageModified)
	{
		// Right-Click doesn't come in here, so start the timing from here
		LOG_WS_FUNCTION_SCOPE_MSG(_T("DeltaView Total Comparison Time"));

		if (!sOptionsFile.IsEmpty() && sOptionsFile.CompareNoCase(CStdString::LoadResource(IDS_TXTEX_customRenderingSet6129,_T("Custom rendering set"))) != 0)/* TXTEX_IGNORE */ 
		{
			if (!RenderingSet::LoadRenderingSetIfRequired(sOptionsFile))
			{
				GetApp()->ShowMessageEx(this->m_hWnd, 
					CStdStringW::LoadResource(IDS_TXTEX_theOptionsFileSpecifiedDoesNotHaveCorrectInformationPleaseMakeSureThisIsaValidOptionsFileCurrentSettingsWillBeApplied5086,_T("The options file specified does not have the correct information - please make sure this is a valid options file.\n\nCurrent settings will be applied.")),
					WsOK,
					WsDefault,
					WsErrorIcon,
					L"",
					CDeltaVwApp::GetProductHelpID(HIDC_INVALID_OPTIONS_FILE),
					LOG_LOCATION);
			}
		}
	}
}
コード例 #17
0
bool OfflineDocIDResolver::SearchOfflineLibrary(const CStdString& sLibraryToSearch, const CStdString& sDocNum, CStdString& sOfflineDocKey ) const
{
    CRegKey key;

    if( key.Open(HKEY_CURRENT_USER, sLibraryToSearch) != ERROR_SUCCESS )
    {
        CStdString sErr = _T("Failed to Open Key : HKCU\\") + sLibraryToSearch;
        LOG_WS_ERROR(sErr.c_str());
        return false;
    }

    DWORD dwIndex = 0;

    long lResult = ERROR_SUCCESS;
    while((lResult == ERROR_SUCCESS || lResult == ERROR_MORE_DATA))
    {
        DWORD dwLength =MAX_PATH;

        lResult = key.EnumKey(dwIndex , sOfflineDocKey.GetBuffer(MAX_PATH), &dwLength , NULL);
        sOfflineDocKey.ReleaseBuffer();
        if(lResult == ERROR_NO_MORE_ITEMS)
            return false;

        DWORD dw = GetDWORDValue(sLibraryToSearch + _T("\\") + sOfflineDocKey, _T("DocNumber"));
        CStdString str;
        str.Format( _T("%d"), dw );
        if( str == sDocNum )
            return true;

        dwIndex++;
    }

    return false;
}
コード例 #18
0
void COptionsDlgSelector::OnOptionsSelect() 
{
	try
	{
		AnalyticsHelper::SendDeltaViewStatistics(L"DeltaView Event: Select to change rendering set");
		CStdString sOptionSetName;
		m_cboOptionsFile.GetWindowText(sOptionSetName.GetBuffer(MAX_PATH), MAX_PATH);
		sOptionSetName.ReleaseBuffer();
		bool bResult = DoShowNewRenderingSetDialog(sOptionSetName.c_str(), GetParent()->m_hWnd, false);

		if(bResult)
		{
			GetApp()->SetShouldRerunComparison(false);

			//// refresh the contents of the rendering options list as it might have changed!!
			std::vector<std::wstring> vecRenderingSets;
			RenderingSet::GetRenderingSetList(vecRenderingSets);

			m_cboOptionsFile.ResetContent();
			PopulateRenderingSetList();


			ResetOKAsDefault(true);
		}
	}
	catch(_com_error &e)
	{
		LOG_WS_ERROR_RESULT(e);
	}
	catch(...)
	{
		_ASSERTE(!_T("Catch ... How did we get here?"));
		LOG_WS_ERROR(_T("Unknown Exception"));
	}
}
コード例 #19
0
CStdStringA TerDateTimeFormatter::GetFormattedTime(SYSTEMTIME& st, const CStdStringA& sFormatPicture)
{
	CStdString sDate;
	int ir = GetTimeFormat(m_locale, 0, &st, sFormatPicture.c_str(), sDate.GetBuffer(MAX_PATH), MAX_PATH);
	sDate.ReleaseBuffer();

	return sDate;
}
コード例 #20
0
ファイル: TestUtils.cpp プロジェクト: killbug2004/WSProf
CStdString CTestUtils::GetLongModuleName()
{
	CStdString sModuleName;
	CStdString sLongModuleName;

	HMODULE hMod = GetModuleHandle(NULL);
	GetModuleFileName(hMod, sModuleName.GetBuffer(MAX_PATH), MAX_PATH);
	sModuleName.ReleaseBuffer();

	DWORD dRet = GetLongPathName(sModuleName, sLongModuleName.GetBuffer(MAX_PATH), MAX_PATH);
	sLongModuleName.ReleaseBuffer();
	if (dRet == 0)
	{
		sLongModuleName = sModuleName;
	}

	return sLongModuleName;
}
コード例 #21
0
CStdStringA TerDateTimeFormatter::GetDefaultTimeFormat()
{
	CStdString sFormat;

	int ir = GetLocaleInfo(m_locale, LOCALE_STIMEFORMAT, sFormat.GetBuffer(MAX_PATH), MAX_PATH);
	sFormat.ReleaseBuffer();
	//GetSystemLocale
	return sFormat;
}
コード例 #22
0
bool MythRecorder::CheckChannel(MythChannel &channel)
{
  m_recorder_t->Lock();
  CStdString channelNum;
  channelNum.Format("%i",channel.Number());
  bool retval=CMYTH->RecorderCheckChannel(*m_recorder_t,channelNum.GetBuffer())==0;
  m_recorder_t->Unlock();
  return retval;
}
コード例 #23
0
ファイル: ServerSocket.cpp プロジェクト: vizcount/work
//初始化
int CServerSocket::Init(int nPort)
{
	WSADATA wsaData;
	int errid;
	int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
	if ( iResult != NO_ERROR )
	{
	    errid = WSAGetLastError();
	    g_log.Trace(LOGL_TOP,LOGT_ERROR,__TFILE__, __LINE__,_T("WSAStartup,错误, error:%d"), errid);
		printf("WSAStartup() 错误:\n");
	}
	// 创建socket
	m_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );

	if ( m_socket == INVALID_SOCKET ) {
		errid = WSAGetLastError();
		g_log.Trace(LOGL_TOP,LOGT_ERROR,__TFILE__, __LINE__,_T("socket,错误, error:%d"), errid);
		printf( "socket() 错误: %ld\n", WSAGetLastError() );
		WSACleanup();
		return -1;
	}

	// 绑定socket
	sockaddr_in service;

	service.sin_family = AF_INET;
	service.sin_addr.s_addr = inet_addr( "127.0.0.1" );
	service.sin_port = htons( nPort );

	if ( ::bind( m_socket, (SOCKADDR*) &service, sizeof(service) ) == SOCKET_ERROR ) {

		::MessageBox(0,_T("舟大师运行时发现一个错误,\r\n请检查是否有第三方软件(如:防火墙)禁止了Mcproc.exe权限\r\n"),_T("\n运行时检测"),MB_OK|MB_ICONWARNING);
#ifdef _DEBUG
		CStdString strErro;
		strErro.Format(_T("bind 端口:%d ,错误码:%d "),nPort, GetLastError());
		::MessageBox(0,strErro.GetBuffer(0),_T("\n运行时检测"),MB_OK|MB_ICONWARNING);
#endif
		closesocket(m_socket);
		WSACleanup();
		return -1;
	}

	// 监听socket
	if ( listen( m_socket, 1 ) == SOCKET_ERROR )
	{
		::MessageBox(0,_T("舟大师运行时发现一个错误,\r\n请检查是否有第三方软件(如:防火墙)禁止了Mcproc.exe权限\r\n"),_T("\n运行时检测"),MB_OK|MB_ICONWARNING);
		closesocket(m_socket);
		WSACleanup();

		return -1;
	}
	m_ClientSocket = INVALID_SOCKET;
	m_bRun = TRUE;
	return 0;
}
コード例 #24
0
bool MythRecorder::SetChannel(MythChannel &channel)
{
  m_recorder_t->Lock();
  if(!IsRecording())
  {
    XBMC->Log(LOG_ERROR,"%s: Recorder %i is not recording",__FUNCTION__,ID(),channel.Name().c_str());
    m_recorder_t->Unlock();
    return false;
  }
  CStdString channelNum;
  channelNum.Format("%i",channel.Number());
  if(CMYTH->RecorderPause(*m_recorder_t)!=0)
  {
    XBMC->Log(LOG_ERROR,"%s: Failed to pause recorder %i",__FUNCTION__,ID());
    m_recorder_t->Unlock();
    return false;
  }
  if(!CheckChannel(channel))
  {
    XBMC->Log(LOG_ERROR,"%s: Recorder %i doesn't provide channel %s",__FUNCTION__,ID(),channel.Name().c_str());
    m_recorder_t->Unlock();
    return false;
  }
  if(CMYTH->RecorderSetChannel(*m_recorder_t,channelNum.GetBuffer())!=0)
  {
    XBMC->Log(LOG_ERROR,"%s: Failed to change recorder %i to channel %s",__FUNCTION__,ID(),channel.Name().c_str());
    m_recorder_t->Unlock();
    return false;
  }
  if(CMYTH->LivetvChainSwitchLast(*m_recorder_t)!=1)
  {
    XBMC->Log(LOG_ERROR,"%s: Failed to switch chain for recorder %i",__FUNCTION__,ID(),channel.Name().c_str());
    m_recorder_t->Unlock();
    return false;
  }
  *livechainupdated=0;
  int i=20;
  while(*livechainupdated==0&&i--!=0)
  {
    m_recorder_t->Unlock();
    cSleep(100);
    m_recorder_t->Lock();
  }

  m_recorder_t->Unlock();
  for(int i=0;i<20;i++)
  {
    if(!IsRecording())
      cSleep(1);
    else
      break;
  }

  return true;
}
コード例 #25
0
ファイル: WinHelper.cpp プロジェクト: Konnekt/staminalib
	std::string regQueryString(HKEY hKey , const char * name, const char * def) {
		unsigned long type=0,count=0;
		if (RegQueryValueEx(hKey,(LPCTSTR)name,0,&type,0,&count) == ERROR_SUCCESS && type == REG_SZ) {
			CStdString buff;
			if (!RegQueryValueEx(hKey,(LPCTSTR)name,0,&type,(LPBYTE)buff.GetBuffer(count-1),&count)) {
				buff.ReleaseBuffer();
				return buff;
			}
		}
		return def ? def : "";
	}
コード例 #26
0
ファイル: MarkupSTL.cpp プロジェクト: Avoidnf8/xbmc-fork
CStdString CMarkupSTL::x_TextFromDoc( int nLeft, int nRight ) const
{
	// Convert XML friendly text to text as seen outside XML document
	// replacing ampersand escape codes with special characters
	// E.g. convert "6&gt;7" to "6>7"
	//
	// Conveniently the result is always the same or shorter in length
	//
	static _TCHAR* szaCode[] = { _T("lt;"),_T("amp;"),_T("gt;"),_T("apos;"),_T("quot;") };
	static int anCodeLen[] = { 3,4,3,5,5 };
	static _TCHAR* szSymbol = _T("<&>\'\"");
	CStdString csText;
	const _TCHAR* pSource = m_csDoc;
	int nDestSize = nRight - nLeft + 1;
	_TCHAR* pDest = csText.GetBuffer(nDestSize);
	int nLen = 0;
	int nCharLen;
	int nChar = nLeft;
	while ( nChar <= nRight )
	{
		if ( pSource[nChar] == _T('&') )
		{
			// Look for matching &code;
			for ( int nMatch = 0; nMatch < 5; ++nMatch )
			{
				if ( nChar <= nRight - anCodeLen[nMatch]
					&& _tcsncmp(szaCode[nMatch],&pSource[nChar+1],anCodeLen[nMatch]) == 0 )
				{
					pDest[nLen++] = szSymbol[nMatch];
					nChar += anCodeLen[nMatch] + 1;
					break;
				}
			}

			// If no match is found it means XML doc is invalid
			// no devastating harm done, ampersand code will just be left in result
			if ( nMatch == 5 )
			{
				pDest[nLen++] = _T('&');
				++nChar;
			}
		}
		else
		{
			nCharLen = _tclen(&pSource[nChar]);
			_tccpy( &pDest[nLen], &pSource[nChar] );
			nLen += nCharLen;
			nChar += nCharLen;
		}
	}
	csText.ReleaseBuffer(nLen);
	return csText;
}
コード例 #27
0
ファイル: MarkupSTL.cpp プロジェクト: Avoidnf8/xbmc-fork
bool CMarkupSTL::Load( const char * szFileName )
{
	CStdString csDoc;
	HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
	if (hFile == INVALID_HANDLE_VALUE)
		return false;
	//The following will not work for files larger than 2GB
	int nLength = GetFileSize(hFile, NULL);

#if defined(_UNICODE)
	// Allocate Buffer for UTF-8 file data
	unsigned char* pBuffer = new unsigned char[nLength + 1];
	DWORD numread;
	if (ReadFile(hFile, pBuffer, nLength, &numread, 0))
		nLength = numread;
	else
		nLength = 0;
	pBuffer[nLength] = '\0';

	// Convert file from UTF-8 to Windows UNICODE (AKA UCS-2)
	int nWideLength = MultiByteToWideChar(CP_UTF8,0,(const char*)pBuffer,nLength,NULL,0);
	nLength = MultiByteToWideChar(CP_UTF8,0,(const char*)pBuffer,nLength,
		csDoc.GetBuffer(nWideLength),nWideLength);
	ASSERT( nLength == nWideLength );
	delete [] pBuffer;
#else
	DWORD numread;
	if (ReadFile(hFile, csDoc.GetBuffer(nLength), nLength, &numread, 0))
		nLength = numread;
	else
		nLength = 0;
#endif
	csDoc.ReleaseBuffer(nLength);
	CloseHandle(hFile);

	return SetDoc( csDoc );
}
コード例 #28
0
bool DotNetRegistrar::UnregisterItem()
{
	CStdString sFileName;
	CStdString sParams;
	CreateUnregisterCommandString(sFileName, sParams);

    CFilePath exePath( GetDotNetRegistrationFileName() ); //this was retrieved in CreateRegisterCommandString, but we want one without enclosing quotes
    CStdStringA sCommand ;
    sCommand.Format("\"%s\" %s", CStdStringA(exePath.GetFileName()), CStdStringA( sParams ) );

    CStdString sBatchFile = GetExecutionPath() + _T("\\Register.bat");
    _tremove( sBatchFile.c_str());
    CreateTextFile( sBatchFile, sCommand );
    ASSERT( CGeneral::FileExists( sBatchFile ));
	
    bool res = true;
    try
    {
	    CStdString cmdLine = sBatchFile;
	    STARTUPINFO si;
	    PROCESS_INFORMATION pi;
	    ZeroMemory(&si, sizeof(si));
	    si.cb = sizeof(si);
	    si.wShowWindow = SW_HIDE;
	    ZeroMemory(&pi, sizeof(pi));
	    if ( !CreateProcess( NULL, cmdLine.GetBuffer(MAX_PATH), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) )
	    {
		    cmdLine.ReleaseBuffer();
		    res = false;

	    }
	    cmdLine.ReleaseBuffer();	
	    if ( res )
	    {
		    // Wait around for 15 seconds 
		    WaitForSingleObject(pi.hProcess, 15000);
		    CloseHandle(pi.hProcess);
		    CloseHandle(pi.hThread);
	    }
    }
    catch(...)
    {
        _tremove( sBatchFile.c_str());
        throw;
    }

    _tremove( sBatchFile.c_str());
	return res;
}
コード例 #29
0
ファイル: xData_item.cpp プロジェクト: Konnekt/kJabber
void cXData::cItem_result::OnDoubleClick(cXData * owner) {
	int pos = ListView_GetSelectionMark(hwnd);
	if (pos == -1 || this->jidColumn == -1)
		return;
	CStdString jid;
	ListView_GetItemText(hwnd, pos, this->jidColumn, jid.GetBuffer(200), 200);
	jid.ReleaseBuffer();
	if (owner->Jab().FindContact(jid) == -1) {
		int id = owner->Jab().GetPlug()->ICMessage(IMC_CNT_ADD, kJabber::net, (int)jid.c_str());
		if (id == -1)
			return;
		owner->Jab().GetPlug()->DTsetStr(DTCNT, id, CNT_GROUP, owner->Jab().GetPlug()->DTgetStr(DTCFG, 0, CFG_CURGROUP));
		owner->Jab().GetPlug()->ICMessage(IMC_CNT_CHANGED, id);
	}
}
コード例 #30
0
ファイル: DefragStorage.cpp プロジェクト: killbug2004/WSProf
CStdString CDefragStorage::GetTempPathName()
{
	CStdString sTempPath;

	::GetTempPath(_MAX_PATH, sTempPath.GetBuffer(_MAX_PATH));
	sTempPath.ReleaseBuffer();

	sTempPath += _T("workshare\\");
	if (!DirectoryExists(sTempPath))
		_tmkdir(sTempPath.c_str());		

	sTempPath += TEMP_FILE_DIR + GetPID() + _T("\\");

	return sTempPath;
}