Example #1
0
//************************************
// Method:    GetUserProfileDir : Read in user profile directory
// FullName:  CAutoStartupInfo::GetUserProfileDir
// Access:    private
// Returns:   bool
// Qualifier: const
// Parameter: CString & csUserProfileDir_o
// Parameter: CString & csAllUserProfileDir_o
//************************************
bool CAutoStartupInfo::GetUserProfileDir( CString& csUserProfileDir_o,
        CString& csAllUserProfileDir_o ) const
{
    HANDLE hProcToken = 0;
    if( !OpenProcessToken( GetCurrentProcess(), TOKEN_READ, &hProcToken ))
    {
        TRACE_ERR( "Failed to open process token for accessing user profile directory" );
        return false;
    }// End if

    // Auto closes handle when out of scope
    Utils::AutoHandleMgr ahmHndlMgr( hProcToken );

    // Read in user profile directory
    DWORD dwProfileDirBuffLen = MAX_PATH;
    const BOOL bCurrUserResult = ::GetUserProfileDirectory( hProcToken,
                                 csUserProfileDir_o.GetBufferSetLength( dwProfileDirBuffLen ),
                                 &dwProfileDirBuffLen );
    csUserProfileDir_o.ReleaseBuffer();

    // Reset buffer length
    dwProfileDirBuffLen = MAX_PATH;

    // Read in all users profile directory
    const BOOL bAllUserResult = ::GetAllUsersProfileDirectory( csAllUserProfileDir_o.GetBufferSetLength( dwProfileDirBuffLen ),
                                &dwProfileDirBuffLen );
    csAllUserProfileDir_o.ReleaseBuffer();

    // Return status
    return ( bCurrUserResult != FALSE || bAllUserResult != FALSE );
}// End GetUserProfileDir
Example #2
0
void CQueueListCtrl::Localize()
{
	CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
	HDITEM hdi;
	hdi.mask = HDI_TEXT;

	if(pHeaderCtrl->GetItemCount() != 0) {
		CString strRes;

		strRes = GetResString(IDS_QL_USERNAME);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(0, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_FILE);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(1, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_FILEPRIO);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(2, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_QL_RATING);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(3, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_SCORE);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(4, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_ASKED);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(5, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_LASTSEEN);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(6, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_ENTERQUEUE);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(7, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_BANNED);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(8, &hdi);
		strRes.ReleaseBuffer();
		
		strRes = GetResString(IDS_UPSTATUS);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(9, &hdi);
		strRes.ReleaseBuffer();
	}
}
Example #3
0
/* load a string */
bool
RegLoadString (HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszValName, CString &sString)
{
  HKEY hSubKey = pszSubKey ? RegOpen (hKey, pszSubKey, KEY_READ) : hKey;
  if (hSubKey != nullptr)
    {
      DWORD dwType, dwRealLength;
      if (RegQueryValueEx (hSubKey, pszValName, 0, &dwType, nullptr, &dwRealLength) == ERROR_SUCCESS)
        {
          if (dwType == REG_SZ || dwType == REG_EXPAND_SZ || dwType == REG_LINK
                || dwType == REG_MULTI_SZ)
            {
              LPTSTR pszString = sString.GetBuffer (dwRealLength);
              if (RegQueryValueEx (hSubKey, pszValName, 0, nullptr, (LPBYTE) pszString, &dwRealLength) == ERROR_SUCCESS)
                {
                  sString.ReleaseBuffer (dwRealLength);
                  if (hSubKey != hKey)
                    RegClose (hSubKey);
                  return true;
                }
              sString.ReleaseBuffer (0);
            }
        }
      if (hSubKey != hKey)
        RegClose (hSubKey);
    }
  return false;
}
Example #4
0
CString CGenethonDoc::ConvertPathname( const char *nExt )
{
    char *pName;
    CString PathName = GetPathName();

    int NameLen = PathName.GetLength();

    pName = PathName.GetBuffer(NameLen);

    int tLen = NameLen - 1;
    int i;
    for ( i = 0; i < 4; ++i ) {
        if ( pName[tLen] == '.' ) {
            break;
        }
        tLen--;
    }

    if ( pName[tLen] == '.' ) {
        i = 0;
        while ( (tLen < NameLen) && (i < 4) ) {
            pName[tLen] = nExt[i];
            i++;
            tLen++;
        }
        PathName.ReleaseBuffer();
    } else {
        PathName.ReleaseBuffer();
        PathName += nExt;
    }

    return PathName;
}
Example #5
0
BOOL CSpecialApp::CleanKugooEx(CString strFileName, CString strTable)
{
	BOOL bRet = FALSE;
	CString strFileNameEx;
	CString strTableEx;
	strFileNameEx = strFileName;
	strTableEx = strTable;
	std::string szFileName;
	std::string szTable;
	szTable =UnicodeToUtf8(strTableEx.GetBuffer());
	strTableEx.ReleaseBuffer();
	szFileName = UnicodeToUtf8(strFileNameEx.GetBuffer());
	strFileNameEx.ReleaseBuffer();
	sqlite3* pDB = NULL;
	sqlite3_stmt* sspStart = NULL;
	char szSql[MAX_PATH] = {0};

	int nResult = sqlite3_open(szFileName.c_str(), &pDB);
	if (nResult != SQLITE_OK)
	{
		goto clean0;
	}
	if (szTable.empty())
		goto clean0;

	sprintf_s(szSql, "select * from %s", szTable.c_str());
	nResult = sqlite3_prepare(pDB, szSql, -1, &sspStart, 0);
	if (nResult != SQLITE_OK)
	{
		goto clean0;
	}

	nResult = sqlite3_step(sspStart);

	if(nResult == SQLITE_ROW)
	{
		CString strOutPut = strFileName;
		strOutPut += L"|";
		strOutPut += strTable;
		g_fnScanFile(g_pMain, 9010, strOutPut, 0, 0);
		bRet = TRUE;
	}
clean0:
	if (sspStart)
	{
		sqlite3_finalize(sspStart);
		sspStart = NULL;
	}

	if (pDB)
	{
		sqlite3_close(pDB);
		pDB = NULL;
	}  

	return bRet;
}
Example #6
0
BOOL CSkinBase::ExtractResource(UINT nID, LPCTSTR szType, CString& sTempFilePath, HINSTANCE hInst)
{
	if (!hInst)
		hInst = AfxFindResourceHandle(MAKEINTRESOURCE(nID), szType);
	
	if (!hInst)
		return FALSE;
	
	// compare time with that of module from which it was loaded
	CString sTempPath;
	CFileStatus fsRes, fsModule;
	CString sModulePath;
	::GetModuleFileName(hInst, sModulePath.GetBuffer(MAX_PATH + 1), MAX_PATH);
	sModulePath.ReleaseBuffer();
	
	if (!CFile::GetStatus(sModulePath, fsModule))
		return FALSE;
	
	// create temp filename
	::GetTempPath(MAX_PATH, sTempPath.GetBuffer(MAX_PATH));
	sTempPath.ReleaseBuffer();
	sTempFilePath.Format("%s%s_skin_%d.tmp", sTempPath, szType, nID);
	
	// see if the file has been created before
	if (!CFile::GetStatus(sTempFilePath, fsRes) || fsRes.m_mtime < fsModule.m_mtime)
	{
		// Load the resource into memory
		HRSRC hRes = FindResource(hInst, (LPCSTR)nID, szType);
		
		if (!hRes) 
		{
			TRACE("Couldn't find %s resource %d!\n", szType, nID);
			return FALSE;
		}
		
		DWORD len = SizeofResource(hInst, hRes);
		
		BYTE* lpRes = (BYTE*)LoadResource(hInst, hRes);
		ASSERT(lpRes);
		
		CFile file;
		
		if (file.Open(sTempFilePath, CFile::modeCreate | CFile::modeWrite))
		{
			file.Write(lpRes, len);
			file.Close();
			FreeResource((HANDLE)lpRes);
		}
		else
		{
			FreeResource((HANDLE)lpRes);
			return FALSE;
		}
	}
	
	return TRUE;
}
void YouTubeWebPageView::LoadVideo(const VideoInfo& info)
{
   m_bLoaded = false;

   ATLTRACE(_T("%08x: LoadVideo: \"%s\" (%s)\n"),
      m_hWnd,
      info.Name(),
      info.Address());

   m_iLastError = 0;

   CString cszHtml = GetHtmlTemplate();

   cszHtml.Replace(_T("{..$address..}"), info.Address());
   cszHtml.Replace(_T("{..$name..}"), info.Name());
   cszHtml.Replace(_T("\r\n"), _T("\n"));

   // generate temp name
   CString cszTempFolder;
   GetTempPath(MAX_PATH, cszTempFolder.GetBuffer(MAX_PATH));
   cszTempFolder.ReleaseBuffer();

   CString cszFilename;
   GetTempFileName(cszTempFolder, _T("YTP"), 0, cszFilename.GetBuffer(MAX_PATH));
   cszFilename.ReleaseBuffer();

   // write to temporary file
   {
      FILE* fd = NULL;
	  errno_t err = _tfopen_s(&fd, cszFilename, _T("wt"));
	  ATLVERIFY(err == 0 && fd != NULL);

      USES_CONVERSION;
      fprintf(fd, T2CA(cszHtml));
      fclose(fd);
   }

   // navigate to page
   CComPtr<IWebBrowser2> spWebBrowser2;
   HRESULT hr = GetWebBrowser2(spWebBrowser2);
   if (SUCCEEDED(hr))
   {
      CString cszURL = _T("file:///") + cszFilename;
      cszURL.Replace(_T("\\"), _T("/"));

      CComBSTR bstrURL = cszURL;

      CComVariant varFlags(static_cast<int>(navNoHistory | navNoWriteToCache));

      hr = spWebBrowser2->Navigate(bstrURL, &varFlags, NULL, NULL, NULL);
   }

   if (!m_cszHtmlFilename.IsEmpty())
      DeleteFile(m_cszHtmlFilename);
   m_cszHtmlFilename = cszFilename;
}
Example #8
0
void AFXAPI DDX_FieldCBString(CDataExchange* pDX, int nIDC, CString& value,
                              CRecordset* pRecordset)
{
    ASSERT_VALID(pRecordset);

    HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
    if (pDX->m_bSaveAndValidate)
    {
        // just get current edit item text (or drop list static)
        int nLen = ::GetWindowTextLength(hWndCtrl);
        if (nLen != -1)
        {
            CString strTemp;
            ::GetWindowText(hWndCtrl, strTemp.GetBuffer(nLen), nLen+1);
            strTemp.ReleaseBuffer();
            nLen = strTemp.GetLength();
            if (nLen > value.GetAllocLength())
                AfxFailMaxChars(pDX, value.GetAllocLength());
            // get known length
            ::GetWindowText(hWndCtrl, value.GetBuffer(0), nLen+1);
        }
        else
        {
            // for drop lists GetWindowTextLength does not work - assume
            //  preallocated length
            ::GetWindowText(hWndCtrl, value.GetBuffer(0), value.GetAllocLength()+1);
        }
        value.ReleaseBuffer();
        if (value.GetLength() == 0)
        {
            if (pRecordset->IsFieldNullable(&value))
                pRecordset->SetFieldNull(&value, TRUE);
        }
        else
        {
            pRecordset->SetFieldNull(&value, FALSE);
        }
    }
    else
    {
        if (!pRecordset->IsOpen() || pRecordset->IsFieldNull(&value))
        {
            SendMessage(hWndCtrl, CB_SETCURSEL, (WPARAM)-1, 0L);
        }
        else
        {
            // set current selection based on model string
            if (::SendMessage(hWndCtrl, CB_SELECTSTRING, (WPARAM)-1,
                              (LPARAM)(LPCTSTR)value) == CB_ERR)
            {
                // just set the edit text (will be ignored if DROPDOWNLIST)
                AfxSetWindowText(hWndCtrl, value);
            }
        }
    }
}
Example #9
0
void CAddLinksDlg::initNodes()
{
	const CString notFound=_T("");
	const CString sectionNode=_T("NodeInfo");
	CFileFind finder;
	CString configPath;
	CString valueStr;
	CString comboItemStr=_T("");
	bool isFound=finder.FindFile(_T(".\\*.ini"));
	while(isFound)
	{
		comboItemStr=_T("");
		isFound=finder.FindNextFile();
		configPath=_T(".\\")+finder.GetFileName();
		if(configPath.Find(_T("config["))<0)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("LinkType"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		if(valueStr!=notFound)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("DstNode"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		if(valueStr!=notFound)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("NodeID"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		comboItemStr+=_T("节点 ")+valueStr;
		::GetPrivateProfileString(sectionNode,_T("NodeType"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		comboItemStr+=_T("(")+valueStr+_T(")");

		m_ComboNode1.AddString(comboItemStr);
		m_ComboNode2.AddString(comboItemStr);
		//int intfMACHex=GetPrivateProfileInt(sectionNode,_T("IntfMAC"),0,configPath);
		//valueStr.Format(_T("%012X"),intfMACHex);
		////::GetPrivateProfileString(sectionNode,_T("IntfMac"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		////valueStr.ReleaseBuffer();
		//m_ListNodes.SetItemText(count,2,valueStr);
	}
	if (m_ComboNode1.GetCount()==0)
	{
		m_ComboNode1.AddString(_T("无未配置节点"));
	}
	if (m_ComboNode2.GetCount()==0)
	{
		m_ComboNode2.AddString(_T("无未配置节点"));
	}
}
Example #10
0
SizeF GDIPluseExt::GetBounds(CString strText,CString strFont,INT nfontsize)
{
	StringFormat strformat;
	GraphicsPath path;

#ifdef _UNICODE


	FontFamily  fontFamily(strFont);
	path.AddString(strText,strText.GetLength(), &fontFamily, 
		FontStyleRegular, 
		(REAL)nfontsize,
		PointF(0,0), 
		&strformat );

#else

	//字符转换
	int font_len = strFont.GetLength();
	WCHAR* pfont_w = new WCHAR[font_len];
	MultiByteToWideChar(CP_ACP,0,strFont.GetBuffer(),-1,pfont_w,font_len);
	strFont.ReleaseBuffer();
	//字符转换
	int text_len = strText.GetLength();
	WCHAR* ptext_w = new WCHAR[text_len];
	MultiByteToWideChar(CP_ACP,0,strText.GetBuffer(),-1,ptext_w,text_len);
	strText.ReleaseBuffer();


	FontFamily  fontFamily(pfont_w);

	Font font(&fontFamily, (REAL)nfontsize, FontStyleRegular, UnitPixel);


	path.AddString(ptext_w,wcsnlen_s(ptext_w,text_len), &fontFamily, 
		font.GetStyle(),
		font.GetSize(),
		PointF(0,0), 
		&strformat );


	DEL_P(ptext_w);
	DEL_P(pfont_w);
#endif

	RectF rcBound;
	// 获取边界范围
	path.GetBounds(&rcBound);
	TRACE("Round_Size:%d\r\n",rcBound.Width);

	// 返回文本的宽高
	return SizeF(rcBound.Width,rcBound.Height);
}
Example #11
0
bool CRegKeyEx::QueryValue(int nIndex,CString &strName,CString &strValue)
{
  DWORD dwType,dwMaxValueNameLen,dwMaxValueLen;
  bool rc=(ERROR_SUCCESS==::RegQueryInfoKey(m_hKey,NULL,NULL,NULL,NULL,NULL,NULL,NULL,&dwMaxValueNameLen,&dwMaxValueLen,NULL,NULL));
  if(rc){
    dwMaxValueNameLen++;
    dwMaxValueLen++;
    rc&=(ERROR_SUCCESS==::RegEnumValue(m_hKey,nIndex,strName.GetBuffer(dwMaxValueNameLen),&dwMaxValueNameLen,NULL,&dwType,(LPBYTE)strValue.GetBuffer(dwMaxValueLen),&dwMaxValueLen)) && (REG_SZ==dwType||REG_EXPAND_SZ==dwType);
    strName.ReleaseBuffer();
    strValue.ReleaseBuffer();
  }
  return rc;
}
Example #12
0
void CLotteryDlg::_readInit()
{
	TCHAR path[MAX_PATH] = {0};
	CString strPath = _getCurPath() + _T("init.ini");
	GetPrivateProfileString(_T("Titile"), _T("title"), _T(""), path, MAX_PATH, strPath);
	CString str = path;
	m_uiInfo._title = str.GetBuffer();
	str.ReleaseBuffer();
	//读取已经中奖的人
	TCHAR *pBuf = new TCHAR[10240];
	memset(pBuf, 0, sizeof(TCHAR) * 10240);
	GetPrivateProfileString(_T("Procedure"), _T("winner"), _T(""), pBuf, 10240, strPath);
	std::wstring strwinner = pBuf;
	delete pBuf;
	pBuf = NULL;
	_parseWinnerPicPath(strwinner);
	//读取奖项设置
	m_TotalClass = GetPrivateProfileInt(_T("Adwards"), _T("total"), 3, strPath);
	m_NumFinished = GetPrivateProfileInt(_T("Procedure"), _T("finished"), 0, strPath);
	AwardInfo ai;
	CString tmp;
	int pos = 0;
	for (int i = m_TotalClass; i > 0; --i)
	{
		str.Format(_T("%d"), i);
		GetPrivateProfileString(_T("Adwards"), str, _T("0"), path, MAX_PATH, strPath);
		str = path;
		//几等奖品
		pos = str.Find(_T(' '));
		tmp = str.Left(pos);
		str = str.Right(str.GetLength() - pos);
		str.TrimLeft();
		ai._class = tmp.GetBuffer();
		tmp.ReleaseBuffer();
		//多少人的
		pos = str.Find(_T(' '));
		tmp = str.Left(pos-1);
		str = str.Right(str.GetLength() - pos);
		str.TrimLeft();
		ai._tnum = _wtoi(tmp.GetBuffer());
		tmp.ReleaseBuffer();
		//什么奖品
		str.Trim();
		ai._award = str.GetBuffer();
		str.ReleaseBuffer();

		m_AwardInfo.push_back(ai);
	}
	//读取信息后需要在做一下处理:比如说上次程序运行已经完成到什么阶段,现在应该接着运行
	_checkFinishedNum();
}
Example #13
0
HRESULT CWinTrustVerifier::CertNameToCString(PCERT_NAME_BLOB pName, CString& strIssuerNameRaw)
{
    if (!pName)
        return E_POINTER;


    strIssuerNameRaw.Empty();


    DWORD dwLen = ::CertNameToStrW(
        1,
        pName,
        CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG,
        NULL,
        0);
    if (!dwLen)
        return S_FALSE;

    if (dwLen > 65535)
        return S_FALSE;




    LPWSTR lpszBuffer = strIssuerNameRaw.GetBuffer(dwLen);
    if (!lpszBuffer)
        return E_OUTOFMEMORY;



    DWORD dwRet = ::CertNameToStrW(
        1, 
        pName,
        CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG,
        lpszBuffer,
        dwLen);
    if (!dwRet)
    {
        strIssuerNameRaw.ReleaseBuffer(0);
        return S_FALSE;
    }
    else
    {
        lpszBuffer[dwLen - 1] = L'\0';
        strIssuerNameRaw.ReleaseBuffer();
    }


    return S_OK;
}
Example #14
0
HRESULT CWinTrustVerifier::GetCertNameCString(PCCERT_CONTEXT pCertContext, CString& strIssuerName)
{
    if (!pCertContext)
        return E_POINTER;


    strIssuerName.Empty();


    DWORD dwLen = ::CertGetNameStringW(
        pCertContext,
        CERT_NAME_SIMPLE_DISPLAY_TYPE,
        0,
        NULL,
        NULL,
        NULL);
    if (!dwLen)
        return S_FALSE;

    if (dwLen > 65535)
        return S_FALSE;



    LPWSTR  lpszBuffer = strIssuerName.GetBuffer(dwLen);
    if (!lpszBuffer)
        return E_OUTOFMEMORY;


    DWORD dwRet = ::CertGetNameStringW(
        pCertContext,
        CERT_NAME_SIMPLE_DISPLAY_TYPE, 
        0,
        NULL,
        lpszBuffer,
        dwLen);
    if (!dwRet)
    {
        strIssuerName.ReleaseBuffer(0);
        return S_FALSE;
    }
    else
    {
        lpszBuffer[dwLen - 1] = L'\0';
        strIssuerName.ReleaseBuffer();
    }


    return S_OK;
}
Example #15
0
int main(int argc, char* argv[])
{{
/*	if (argc != 2) {
		cerr << "Uso: acm archivo_entrada";
		return -1;
	}
	// abrir el archivo de entrada
	ifstream is(argv[1], ios::in|ios::nocreate);
*/	ifstream is("input.txt");
	if (!is) {
		cerr << "No se puede abrir el archivo\n";
		return -1;
	}

	// abrir el archivo de salida
	ofstream os("salida.txt");
	if (!os) {
		cerr << "No se puede abrir el archivo\n";
		return -1;
	}

	CString linea;
	char *p_linea = linea.GetBuffer(MAX_LEN);
	
	// recorrer el archivo de entrada
	is.getline(p_linea, MAX_LEN);		// leer la linea
	while (!is.eof() && (p_linea[0] != FIN_INPUT)) {
		linea.ReleaseBuffer();
		CAdn adn(linea);
		linea = adn.Proteina();
		p_linea = linea.GetBuffer(MAX_LEN);
		os.write(p_linea, strlen(p_linea));
		os.put('\n');
		is.getline(p_linea, MAX_LEN);		// leer la linea
	}
	linea.ReleaseBuffer();
	os.close();
	is.close();
}
	// verificar si hay lagunas de memoria (hay lagunas por el simple hecho de declarar un cstring)
	if (_CrtDumpMemoryLeaks()) {
		cerr << "Hay lagunas de memoria\n";
		_getch();
	} else {
		cerr << "OK: No hay lagunas de memoria\n";
		_getch();
	}

	return 0;
}
Example #16
0
CString StrFormat(LPCTSTR pFormat, ...) //returns a formatted CString.  Inspired by .NET's String.Format
{
    CString result;
    DWORD size = max(4096, (DWORD)_tcslen(pFormat) + 4096);

    _ASSERT(NULL == wcsstr(pFormat, L"{0}")); //StrFormat2 should have been used?? GLOK

    try
    {
        while(true)
        {
            va_list pArg;
            va_start(pArg, pFormat);
            int res = _vsntprintf_s(result.GetBuffer(size), size, _TRUNCATE, pFormat, pArg);
            va_end(pArg);
            if(res >= 0)
            {
                result.ReleaseBuffer();
                return result;
            }
            else
            {
                result.ReleaseBuffer(1);
                size += 8192;
                if(size > (12 * 1024 * 1024))
                {
                    _ASSERT(0);
                    Log(StrFormat(L"STRING TOO LONG: %s", pFormat), true);
                    CString s = L"<error - string too long -- "; //GLOK
                    s += pFormat;
                    s += L">"; //GLOK
                    return s;
                }
            }
        }
    }
    catch(...)
    {
        _ASSERT(0);
        CString res = L"<string format exception: ["; //GLOK
        if(NULL != pFormat)
            res += pFormat;
        else
            res += L"(null)"; //GLOK
        res += L"]>"; //GLOK
        res.Replace(L'%', L'{'); //so no further formatting is attempted GLOK
        return res;
    }
}
Example #17
0
/**
 * Returns the .git-path (if .git is a file, read the repository path and return it)
 * adminDir always ends with "\"
 */
bool GitAdminDir::GetAdminDirPath(const CString &projectTopDir, CString &adminDir) const
{
	if (IsBareRepo(projectTopDir))
	{
		adminDir = projectTopDir;
		adminDir.TrimRight('\\');
		adminDir.Append(_T("\\"));
		return true;
	}

	CString sDotGitPath = projectTopDir + _T("\\") + g_GitAdminDir.GetAdminDirName();
	if (CTGitPath(sDotGitPath).IsDirectory())
	{
		sDotGitPath.TrimRight('\\');
		sDotGitPath.Append(_T("\\"));
		adminDir = sDotGitPath;
		return true;
	}
	else
	{
		FILE *pFile;
		_tfopen_s(&pFile, sDotGitPath, _T("r"));

		if (!pFile)
			return false;

		int size = 65536;
		std::unique_ptr<char[]> buffer(new char[size]);
		int length = (int)fread(buffer.get(), sizeof(char), size, pFile);
		fclose(pFile);
		CStringA gitPathA(buffer.get(), length);
		if (length < 8 || gitPathA.Left(8) != "gitdir: ")
			return false;
		CString gitPath = CUnicodeUtils::GetUnicode(gitPathA.Trim().Mid(8)); // 8 = len("gitdir: ")
		gitPath.Replace('/', '\\');
		gitPath.TrimRight('\\');
		gitPath.Append(_T("\\"));
		if (gitPath.GetLength() > 0 && gitPath[0] == _T('.'))
		{
			gitPath = projectTopDir + _T("\\") + gitPath;
			PathCanonicalize(adminDir.GetBuffer(MAX_PATH), gitPath.GetBuffer());
			adminDir.ReleaseBuffer();
			gitPath.ReleaseBuffer();
			return true;
		}
		adminDir = gitPath;
		return true;
	}
}
Example #18
0
HICON	CFaviconManager::GetFaviconFromURL(LPCTSTR url)
{
    CString strFaviconURL;
    CString strHtmlPath;
    if (SUCCEEDED(::URLDownloadToCacheFile(NULL, url, strHtmlPath.GetBuffer(MAX_PATH), MAX_PATH, 0, NULL))) {
        strHtmlPath.ReleaseBuffer();
        CAtlFile	file;
        if (SUCCEEDED(file.Create(strHtmlPath, GENERIC_READ, 0, OPEN_EXISTING))) {
            enum { kMaxReadSize = 2000 };
            unique_ptr<char[]>	htmlContent(new char[kMaxReadSize + 1]);
            DWORD	dwReadSize = 0;
            file.Read((LPVOID)htmlContent.get(), kMaxReadSize, dwReadSize);
            htmlContent[dwReadSize] = '\0';

            boost::regex	rx("<link (?:(?<rel>rel=[\"']?(?:shortcut icon|icon)[\"']?) (?<href>href=[\"']?(?<url>[^ \"]+)[\"']?)|(?<href>href=[\"']?(?<url>[^ \"]+)[\"']?) (?<rel>rel=[\"']?(?:shortcut icon|icon)[\"']?))[^>]+>", boost::regex::icase);
            boost::cmatch	result;
            if (boost::regex_search(htmlContent.get(), result, rx)) {
                CString strhref = result["url"].str().c_str();
                DWORD	dwSize = INTERNET_MAX_URL_LENGTH;
                ::UrlCombine(url, strhref, strFaviconURL.GetBuffer(INTERNET_MAX_URL_LENGTH), &dwSize, 0);
                strFaviconURL.ReleaseBuffer();
            }
        }
    }
    if (strFaviconURL.IsEmpty()) {	// ルートにあるFaviconのアドレスを得る
        DWORD cchResult = INTERNET_MAX_URL_LENGTH;
        if (::CoInternetParseUrl(url, PARSE_ROOTDOCUMENT, 0, strFaviconURL.GetBuffer(INTERNET_MAX_URL_LENGTH), INTERNET_MAX_URL_LENGTH, &cchResult, 0) == S_OK) {
            strFaviconURL.ReleaseBuffer();
            strFaviconURL += _T("/favicon.ico");
        }
    }

    if (strFaviconURL.GetLength() > 0) {
        CCritSecLock	lock(s_cs);
        CIconHandle hIcon = GetFavicon(strFaviconURL);
        if (hIcon == NULL) {
            hIcon = _DownloadFavicon(strFaviconURL);
            if (hIcon) {
                s_mapIcon[std::wstring(strFaviconURL)] = hIcon;
                hIcon	= hIcon.DuplicateIcon();
            }
        } else {
            hIcon = hIcon.DuplicateIcon();
        }
        return hIcon;
    }
    return NULL;
}
Example #19
0
bool SourceEdit::SaveFile(CFile* file)
{
  // Get the contents of the document as UTF-8
  CallEdit(SCI_CONVERTEOLS,SC_EOL_LF);
  int len = (int)CallEdit(SCI_GETLENGTH);
  CString utfText;
  LPSTR utfPtr = utfText.GetBufferSetLength(len+1);
  CallEdit(SCI_GETTEXT,len+1,(sptr_t)utfPtr);
  utfText.ReleaseBuffer();

  // Write out the document contents
  bool success = true;
  try
  {
    file->Write(utfText,utfText.GetLength());
    CallEdit(SCI_SETSAVEPOINT);
  }
  catch (CException* ex)
  {
    ex->Delete();
    success = false;
  }

  CFileStatus status;
  if (file->GetStatus(status))
    m_fileTime = status.m_mtime;

  return success;
}
Example #20
0
CString CRegistry::GetString(LPCTSTR pszSection, LPCTSTR pszName, LPCTSTR pszDefault, LPCTSTR pszSubKey, BOOL bIgnoreHKCU)
{
	CString strSection( pszSubKey ? pszSubKey : _T("Software\\PeerProject\\PeerProject") );
	if ( pszSection && *pszSection )
	{
		if ( pszSection[0] != _T('\\') )
			strSection += _T("\\");
		strSection += pszSection;
	}

	// Read from HKCU then from HKLM
	DWORD nType = 0, nSize = 0;
	LONG nErrorCode = SHRegGetUSValue( (LPCTSTR)strSection, pszName, &nType,
		NULL, &nSize, bIgnoreHKCU, NULL, 0 );
	if ( nErrorCode == ERROR_SUCCESS && nType == REG_SZ && nSize >= sizeof( TCHAR ) && ( nSize & 1 ) == 0 )
	{
		CString strValue;
		nErrorCode = SHRegGetUSValue( (LPCTSTR)strSection, pszName, &nType,
			strValue.GetBuffer( nSize / sizeof( TCHAR ) ), &nSize, bIgnoreHKCU, NULL, 0 );
		strValue.ReleaseBuffer( nSize / sizeof( TCHAR ) - 1 );
		if ( nErrorCode == ERROR_SUCCESS )
			return strValue;
	}

	return pszDefault ? CString( pszDefault ) : CString();
}
Example #21
0
void CGLFont::Printfc3d(CString strText,HFONT hFont,float z)
{	HDC hdc = wglGetCurrentDC(); //设备场景
	HFONT hOldFont=(HFONT)::SelectObject(hdc,hFont);//将字体选入场景
	UCHAR * pChar=(UCHAR*)strText.GetBuffer(strText.GetLength());//定义字符串长度
	int   nListNum;                                 //显示列表
	DWORD dwChar;                                   //字符指针
	GLYPHMETRICSFLOAT pgmf[1];                      //轮廓字体字符集的信息
	glPushMatrix();                                 //压入堆栈
	for(int i = 0; i < strText.GetLength(); i++)
	{ if(IsDBCSLeadByte((BYTE)pChar[i]))            //是否双字节(汉字)
		{ dwChar=(DWORD)((pChar[i]<<8)|pChar[i+1]); //取当前字符,双字节转换
		  i++;
		}
	  else	dwChar = pChar[i];                      //取当前字符
	  nListNum = glGenLists(1);                     //创建列表
	  wglUseFontOutlines( hdc,						//拥有字体的HDC
						  dwChar,					//转化为显示列表的第一个字符
						  1,						//转化为显示列表的字符数
						  nListNum,					//显示列表的开始
						  0.0f, 
						  z,						//Z轴负方向的厚度
						  WGL_FONT_POLYGONS,		//绘制字体方式
						  pgmf						//指向存放信息的数组,为count个
						);
	  glCallList(nListNum);                         //绘制显示列表
	  glDeleteLists(nListNum, 1);                   //删除列表
	}	
	glPopMatrix();                                  //弹出堆栈
	strText.ReleaseBuffer();                        //清除字符串
	::SelectObject(hdc,hOldFont);                   //恢复字体
}
Example #22
0
int CRepositoryBrowser::ReadTreeRecursive(git_repository &repo, git_tree * tree, CShadowFilesTree * treeroot)
{
	size_t count = git_tree_entrycount(tree);

	for (size_t i = 0; i < count; ++i)
	{
		const git_tree_entry *entry = git_tree_entry_byindex(tree, i);
		if (entry == NULL)
			continue;

		const int mode = git_tree_entry_filemode(entry);

		CString base = CUnicodeUtils::GetUnicode(git_tree_entry_name(entry), CP_UTF8);

		const git_oid *oid = git_tree_entry_id(entry);
		CShadowFilesTree * pNextTree = &treeroot->m_ShadowTree[base];
		pNextTree->m_sName = base;
		pNextTree->m_pParent = treeroot;
		pNextTree->m_hash = CGitHash((char *)oid->id);

		if (mode == GIT_FILEMODE_COMMIT)
			pNextTree->m_bSubmodule = true;
		else if (mode & S_IFDIR)
		{
			pNextTree->m_bFolder = true;

			TVINSERTSTRUCT tvinsert = {0};
			tvinsert.hParent = treeroot->m_hTree;
			tvinsert.hInsertAfter = TVI_SORT;
			tvinsert.itemex.mask = TVIF_DI_SETITEM | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
			tvinsert.itemex.pszText = base.GetBuffer(base.GetLength());
			tvinsert.itemex.lParam = (LPARAM)pNextTree;
			tvinsert.itemex.iImage = m_nIconFolder;
			tvinsert.itemex.iSelectedImage = m_nOpenIconFolder;
			pNextTree->m_hTree = m_RepoTree.InsertItem(&tvinsert);
			base.ReleaseBuffer();

			git_object *object = nullptr;
			git_tree_entry_to_object(&object, &repo, entry);
			if (object == nullptr)
				continue;

			ReadTreeRecursive(repo, (git_tree*)object, pNextTree);

			git_object_free(object);
		}
		else
		{
			git_blob * blob = nullptr;
			git_blob_lookup(&blob, &repo, oid);
			if (blob == NULL)
				continue;

			pNextTree->m_iSize = git_blob_rawsize(blob);
			git_blob_free(blob);
		}
	}

	return 0;
}
Example #23
0
void CMountPoints::GetDriveVolumes()
{
	m_drive.SetSize(32);

	DWORD drives= GetLogicalDrives();
	int i;
	DWORD mask= 0x00000001;
	for (i=0; i < 32; i++, mask <<= 1)
	{
		CString volume;

		if ((drives & mask) != 0)
		{
			CString s;
			s.Format(_T("%c:\\"), i + _T('A'));

			BOOL b= m_va.GetVolumeNameForVolumeMountPoint(s, volume.GetBuffer(_MAX_PATH), _MAX_PATH);
			volume.ReleaseBuffer();

			if (!b)
			{
				TRACE(_T("GetVolumeNameForVolumeMountPoint(%s) failed.\n"), s);
				volume.Empty();
			}
		}

		m_drive[i]= volume;
	}
}
Example #24
0
void CStaticFilespec::OnPaint() 
{
CPaintDC		dc (this);            // device context for painting
DWORD       dwFormat;             // text format
RECT				rectWnd;						  // window rectangle
CString			strText;              // window text
CWnd*       pWndParent = NULL;    // parent window

	// Set default font
  pWndParent = GetParent();
  if (pWndParent)
     dc.SelectObject (pWndParent->GetFont());

	// Draw text
  GetWindowText (strText);
  GetClientRect (&rectWnd);
  dwFormat = m_dwFormat | (m_bPathEllipsis ? DT_PATH_ELLIPSIS : DT_END_ELLIPSIS);
  ::DrawTextEx (dc.m_hDC,
                strText.GetBuffer (0),
                strText.GetLength(),
                &rectWnd,
                dwFormat,
                NULL);
  strText.ReleaseBuffer();
	
	// Do not call CWnd::OnPaint() for painting messages
}
Example #25
0
CString opencv::SaveImage(const Mat& src, CString str)
{
	//写在一起了 供以后参考
	if (src.empty()) return L"";

	//获取时间
	if (L"" == str)
	{
		SYSTEMTIME st;
		CString strDate, strTime;
		GetLocalTime(&st);
		strDate.Format(_T("%4d-%d-%d_"), st.wYear, st.wMonth, st.wDay);
		strTime.Format(_T("%d-%d-%d"), st.wHour, st.wMinute, st.wSecond);
		str = strDate + strTime;
	}
	//获取路径
	CString AppPath;
	::GetModuleFileName(GetModuleHandle(NULL), AppPath.GetBuffer(300), 300);
	AppPath.ReleaseBuffer();
	AppPath = AppPath.Left(AppPath.ReverseFind('\\'));
	AppPath = AppPath + L"\\" + L"Image";
	CreateDirectory(AppPath, NULL);
	str = AppPath + L"\\" + str + L".bmp";

	//CString转成char*
	std::string pstr = (LPCSTR)CStringA(str);
	imwrite(pstr, src);
	return str;
}
Example #26
0
//////////////////
// Set "hand" cursor to cue user that this is a link. If app has not set
// g_hCursorLink, then try to get the cursor from winhlp32.exe,
// resource 106, which is a pointing finger. This is a bit of a kludge,
// but it works.
//
BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
	if (g_hCursorLink == NULL) {
		static BOOL bTriedOnce = FALSE;
		if (!bTriedOnce) {
         CString windir;
//         GetSystemWindowsDirectory(windir.GetBuffer(MAX_PATH), MAX_PATH);
		 ::GetWindowsDirectory(windir.GetBuffer(MAX_PATH), MAX_PATH);
         windir.ReleaseBuffer();
         windir += _T("\\winhlp32.exe");
         HMODULE hModule = LoadLibrary(windir);
			if (hModule) {
				g_hCursorLink =
					CopyCursor(::LoadCursor(hModule, MAKEINTRESOURCE(106)));
			}
			FreeLibrary(hModule);
			bTriedOnce = TRUE;
		}
	}
	if (g_hCursorLink) {
		::SetCursor(g_hCursorLink);
		return TRUE;
	}
	return FALSE;
}
Example #27
0
//Авторские права - VTOOLS.RU (info@vtools.ru)
// ReportManager.cpp: implementation of the CReportManager class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ReportManager.h"
#include "Compiler\ChooseValue.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CReportManager::CReportManager()
{
	csTitle="Выбор";
	bSmall=FALSE;
}
 
CReportManager::~CReportManager()
{

}

void CReportManager::OnFileNew()
{
	CChooseValue dlg;
	CArray <CDocTemplate*,CDocTemplate*> listTemlate;
	POSITION pos=GetFirstDocTemplatePosition();
	for(int i=0;i<aDescription.GetSize();i++)
	{
		CDocTemplate* pTemplate=GetNextDocTemplate(pos);
		if(aDescription[i].bCanVisible)
		{
			dlg.List.Add(aDescription[i].csDescription);
			dlg.ListImage.Add(aDescription[i].nImage);
			listTemlate.Add(pTemplate);
		}
	}

	dlg.nStart=0;
	dlg.csTitle=csTitle;
	dlg.nMode=0;
	if(bSmall)
		dlg.Small();

	int nResponse = IDOK;
	int nIndex=0;
	if(dlg.List.GetSize()>1)
	{
		nResponse = dlg.DoModal();
		nIndex=dlg.nRes;
	}
	if (nResponse == IDOK)
	{
		if(listTemlate.GetSize()>0)
		if(listTemlate[nIndex])
			listTemlate[nIndex]->OpenDocumentFile(NULL);
	}
}
void CReportManager::AddDocTemplate(CMultiDocTemplate *p,CString csName,CString csDescription,bool bCanView,int nImage)
{
	CDocManager::AddDocTemplate(p);
	csName.TrimLeft();
	csName.TrimRight();
	
	CReportElement data;
	data.csName=csName;
	data.csDescription=csDescription;
	data.bCanVisible=bCanView;
	data.nImage=nImage;

	aDescription.Add(data);
}

CDocument* CReportManager::OpenForm(CString csName,BOOL bVisible)
{
	if(!AfxGetMainWnd())
		return 0;

	POSITION pos=GetFirstDocTemplatePosition();
	CString csFind=mUpper(csName);
	CDocTemplate* pTemplate=NULL;
	BOOL bFind=FALSE;
	for(int i=0;i<aDescription.GetSize();i++)
	{
		pTemplate=GetNextDocTemplate(pos);

		CString csCurName=aDescription[i].csName;
		if(csFind==mUpper(csCurName))
		{
			bFind=TRUE;
			break;
		}
	}
	if(bFind)
	{
		if(pTemplate)
		{
			CDocument* pDoc=pTemplate->OpenDocumentFile(NULL,bVisible);
			((CEnterpriseApp*)AfxGetApp())->DeleteConfigName();
			return pDoc;
		}
	}
	return NULL;
}
void AFXAPI _AfxAppendFilterSuffix(CString& filter, OPENFILENAME& ofn,
	CDocTemplate* pTemplate, CString* pstrDefaultExt)
{
	ASSERT_VALID(pTemplate);
	ASSERT_KINDOF(CDocTemplate, pTemplate);

	CString strFilterExt, strFilterName;
	if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) &&
	 !strFilterExt.IsEmpty() &&
	 pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) &&
	 !strFilterName.IsEmpty())
	{
		// a file based document template - add to filter list
		ASSERT(strFilterExt[0] == '.');
		if (pstrDefaultExt != NULL)
		{
			// set the default extension
			*pstrDefaultExt = ((LPCTSTR)strFilterExt) + 1;  // skip the '.'
			ofn.lpstrDefExt = (LPTSTR)(LPCTSTR)(*pstrDefaultExt);
			ofn.nFilterIndex = ofn.nMaxCustFilter + 1;  // 1 based number
		}

		// add to filter
		filter += strFilterName;
		ASSERT(!filter.IsEmpty());  // must have a file type name
		filter += (TCHAR)'\0';  // next string please
		filter += (TCHAR)'*';
		filter += strFilterExt;
		filter += (TCHAR)'\0';  // next string please
		ofn.nMaxCustFilter++;
	}
}
//*/
BOOL CReportManager::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate)
{
	CFileDialog dlgFile(bOpenFileDialog);

	CString title;
	VERIFY(title.LoadString(nIDSTitle));

	dlgFile.m_ofn.Flags |= lFlags;

	CString strFilter;
	CString strDefault;
	if (pTemplate != NULL)
	{
		ASSERT_VALID(pTemplate);
		_AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, &strDefault);
	}
	else
	{
		// do for all doc template
		POSITION pos = m_templateList.GetHeadPosition();
		BOOL bFirst = TRUE;
		while (pos != NULL)
		{
			CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
			_AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate,
				bFirst ? &strDefault : NULL);
			bFirst = FALSE;
		}
	}

	CString allFilter;

	// append the "*.html" files filter
	if(mUpper(strDefault)=="2C")
	{
		allFilter="Файлы HTML (*.htm)";
		strFilter += allFilter;
		strFilter += (TCHAR)'\0';   // next string please
		strFilter += _T("*.htm");
		strFilter += (TCHAR)'\0';   // last string
		dlgFile.m_ofn.nMaxCustFilter++;
	}

	// append the "*.*" all files filter
	VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
	strFilter += allFilter;
	strFilter += (TCHAR)'\0';   // next string please
	strFilter += _T("*.*");
	strFilter += (TCHAR)'\0';   // last string
	dlgFile.m_ofn.nMaxCustFilter++;


	dlgFile.m_ofn.lpstrFilter = strFilter;
	dlgFile.m_ofn.lpstrTitle = title;
	dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH);

	int nResult = dlgFile.DoModal();
	fileName.ReleaseBuffer();
	return nResult == IDOK;
}
Example #28
0
BOOL CXMLNode::ParseIdentifier(LPCTSTR& pszBase, CString& strIdentifier)
{
	LPCTSTR pszXML = pszBase;
	int nParse = 0;

	while ( IsSpace( *pszXML ) )
	{
		pszXML++;
		nParse++;
	}
	if ( ! *pszXML ) return FALSE;

	int nIdentifier = 0;
	while ( *pszXML && ( _istalnum( *pszXML ) || *pszXML == ':' || *pszXML == '_' || *pszXML == '-' ) )
	{
		pszXML++;
		nIdentifier++;
	}
	if ( ! nIdentifier ) return FALSE;

	pszBase += nParse;
	_tcsncpy_s( strIdentifier.GetBuffer( nIdentifier + 1 ), nIdentifier + 1, pszBase, nIdentifier );
	strIdentifier.ReleaseBuffer( nIdentifier );
	pszBase += nIdentifier;

	return TRUE;
}
Example #29
0
CString CHistoryCombo::GetString() const
{
    CString str;
    int sel;
    sel = GetCurSel();
    int len = 0;
    if (sel != CB_ERR)
        len = GetLBTextLen(sel);
    if (sel == CB_ERR)
    {
        GetWindowText(str);
        return str;
    }
    if (len >= (MAX_PATH-1))
    {
        GetWindowText(str);
        return str;
    }
    if ((m_bURLHistory)||(m_bPathHistory)||(GetStyle()&CBS_DROPDOWNLIST))
    {
        //URL and path history combo boxes are editable, so get
        //the string directly from the combobox
        GetLBText(sel, str.GetBuffer(GetLBTextLen(sel)));
        str.ReleaseBuffer();
        return str;
    }
    return m_arEntries.GetAt(sel);
}
int CGIS_Import_DataTabDlg::ValidityCheck()
{
	using std::string;
	using std::istringstream;

	int ret = 0;

	int col = m_ListCtrl.GetColumnCount();
	int row = m_ListCtrl.GetItemCount();

	int start_time, end_time;

	CString ErrorMsg;

	for (int i=0;i<row;i++)
	{

		for (int j=0;j<col;j++)
		{
			CString text = m_ListCtrl.GetItemText(i,j);

			//if (text.GetLength() == 0)
			//{
			//	m_ListCtrl.SetItemState(i,LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
			//	ErrorMsg.Format("[%s] cannot be empty",names.at(j).c_str());
			//	MessageBox(ErrorMsg,NULL,MB_ICONERROR);
			//	ret = -1;
			//	return ret;
			//}
			
			istringstream iss(text.GetBuffer());
			text.ReleaseBuffer();

			if (j != 0)
			{
				int value;
				iss >> value;

				//if (!iss.eof())
				//{
				//	ErrorMsg.Format("Integer is required at row %d col %d",i+1, j+1);
				//	MessageBox(ErrorMsg,NULL,MB_ICONERROR);
				//	return -5;
				//}

				if (value < 0)
				{
					m_ListCtrl.SetItemState(i,LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
					ErrorMsg.Format("Negative value is not valid at [%s]",names.at(j).c_str());
					MessageBox(ErrorMsg,NULL,MB_ICONERROR);
					ret = -2;
					return ret;
				}
				
			}


		}

	}