Beispiel #1
0
BOOL CDirTreeCtrl::IsValidPath(LPCTSTR strPath)
{
	// This function check the Pathname
	
	HTREEITEM hChild;
	CString   strItem;
	CString   strTempPath = strPath;
	BOOL      bFound = FALSE;
	CFileFind find;

	hChild = GetChildItem( TVI_ROOT );
	strTempPath.MakeUpper();
	strTempPath.TrimRight('\\');

	while ( hChild )
	{
		strItem = GetItemText( hChild );
		strItem.MakeUpper();
		if ( strItem == strTempPath.Mid( 0, strItem.GetLength() ) )
		{
			bFound = TRUE;
			break;
		}
		hChild = GetNextItem( hChild, TVGN_NEXT );
	}
    
	if ( !bFound )
		return FALSE;

	strTempPath += _T("\\nul");
	if ( find.FindFile( strTempPath ) )
		return TRUE;
     
	return FALSE;
}
//**************************************************************************
int CBCGPRibbonComboBox::FindItemByPrefix(LPCTSTR lpszPrefix, CString& strResult) const
{
	ASSERT_VALID (this);
	ASSERT (lpszPrefix != NULL);

	strResult.Empty();

	CString strPrefix = lpszPrefix;
	strPrefix.MakeUpper();

	int iIndex = 0;
	for (POSITION pos = m_lstItems.GetHeadPosition (); pos != NULL; iIndex++)
	{
		CString strItem = m_lstItems.GetNext (pos);
		strItem.MakeUpper();

		if (strItem.Find(strPrefix) == 0)
		{
			strResult = GetItem(iIndex);
			return iIndex;
		}
	}

	return -1;
}
Beispiel #3
0
int CProcessDlg::OnVKeyToItem( UINT nKey, CListBox* pListBox, UINT nIndex )
{
	if (m_title != _T("Process"))
		return false;

	UINT count = pListBox->GetCount();

	UINT cur = nIndex + 1;
	if (cur >= count)
		return -2;

	CString keyStr;
	keyStr.Format(_T(" %c"), nKey);
	keyStr = keyStr.MakeUpper();

	CString txt;
	while (cur != nIndex) {
		pListBox->GetText(cur, txt);
		txt = txt.MakeUpper();
		if (txt.Find(keyStr) != -1) {
			pListBox->SetCurSel(cur);
			break;
		}

		cur = (cur + 1) % count;
	}

	return -2;
}
BOOL CDomainListBox::SelectShortname( int nStart, CString strText )
{
	SelectItem( -1, FALSE );

	strText.MakeUpper();
	int	nLen	=	strText.GetLength();
	if( nLen <= 0 )
		return FALSE;

	CString	rString;
	int	nPos	=	nStart;
	for( int i=0; i<GetCount(); i++ )
	{
		if( nPos == GetCount() || nPos < 0 )
			nPos	=	0;

		GetText( nPos, rString );
		rString.MakeUpper();
		int	nIndex	=	rString.Find( '(' );
		if( -1 != nIndex )
		{
			rString	=	rString.Mid( nIndex+1 );
			if( 0 == strncmp( rString, strText, min(nLen,rString.GetLength()) ) )
			{
				SelectItem( i, TRUE );
				SetTopIndex( i > 6 ? i-6 : 0 );
				return TRUE;
			}
		}

		nPos	++;
	}
	return FALSE;
}
Beispiel #5
0
 bool matches(CTreeListItem * tli)
 {
     LPCSTR name = tli->getName(NULL), value = tli->getValue();
     if(matchCase)
     {
         if(strstr(name, findWhat)) return true;
         if(value && !tli->isBinary() && strstr(value, findWhat)) return true;           
     }
     else
     {
         static CString what, nbuf;
         what = findWhat;
         nbuf = name;
         what.MakeUpper();
         nbuf.MakeUpper();
         if(strstr(nbuf, what)) return true;     
         if(value && !tli->isBinary())
         {
             static CString vbuf;
             vbuf= value;
             vbuf.MakeUpper();
             if(strstr(vbuf, what)) return true;
         }
     }
     return false;
 }
Beispiel #6
0
int CMimicFile::GetMimicList(vector<CString>& MimicInfoList)
{
	DWORD t1 = GetTickCount();
	char				SrcfilePathFile[255];
	WIN32_FIND_DATA     FindFileData;
	HANDLE				handle;
	MimicInfoList.clear();

	//获取系统图存放路径
	char SrcfilePath[255];
	GetPrivateProfileString("Drawings Dir", "MimicPath", "C:\\Drawings", SrcfilePath, 255, MIMICSYSCONFINI);

	//判断路径是否存在
	if (_access(SrcfilePath, 0) == -1)
	{
		return -1;
	}
	sprintf_s(SrcfilePathFile, "%s\\*.grb", SrcfilePath);
	handle = FindFirstFile(SrcfilePathFile, &FindFileData);
	if (handle != INVALID_HANDLE_VALUE)
	{
		BOOL		bResult = TRUE;
		CString		csGrb;
		while (bResult)
		{
			csGrb.Format("%s", FindFileData.cFileName);
			if(csGrb.GetLength() != 12)
			{
				bResult = FindNextFile(handle, &FindFileData);
				continue;
			}
			csGrb.MakeUpper();
			csGrb = csGrb.Left(8);

			//检查图是否合法的图
			if(CheckGrbValid(csGrb) == TRUE)
			{
				MimicInfoList.push_back(csGrb);

				//修改文件名为全大写
				CString OriFile = FindFileData.cFileName;
				CString DstFile = OriFile;
				if (OriFile != DstFile.MakeUpper())
				{
					CString PathFile;
					PathFile.Format("%s\\%s", SrcfilePath, DstFile);
					BOOL b = MoveFile(PathFile, PathFile);
				}
			}
			bResult = FindNextFile(handle, &FindFileData);
		}
	}
	FindClose(handle);

	DWORD t2 = GetTickCount();
	TRACE("GetMimicInfoList()耗时=%dms\n", t2 - t1);

	return (int)MimicInfoList.size();
}
Beispiel #7
0
/****************************************************************************
*
*	FUNCTION:	SearchTree(	HTREEITEM treeNode,
*							CString szSearchName )
*
*	PURPOSE:	Too crude to explain, just use it
*
*	WARNING:	Only works if you use the default PopulateTree()
*				Not guaranteed to work on any future or existing
*				version of windows. Use with caution. Pretty much
*				ok if you're using on local drives
*
****************************************************************************/
bool CShellTreeCtrl::SearchTree(HTREEITEM treeNode,
							CString szSearchName,
							FindAttribs attr)
{
	LPTVITEMDATA	lptvid;  //Long pointer to TreeView item data
	LPSHELLFOLDER	lpsf2=NULL;
	char	drive[_MAX_DRIVE];
	char	dir[_MAX_DIR];
	char	fname[_MAX_FNAME];
	char	ext[_MAX_EXT];
	bool	bRet=false;
	HRESULT	hr;
	CString	szCompare;

	szSearchName.MakeUpper();
	while(treeNode && bRet==false)
	{
		lptvid=(LPTVITEMDATA)GetItemData(treeNode);
		if (lptvid && lptvid->lpsfParent && lptvid->lpi)
		{
			hr=lptvid->lpsfParent->BindToObject(lptvid->lpi,
					 0,IID_IShellFolder,(LPVOID *)&lpsf2);
			if (SUCCEEDED(hr))
			{
				ULONG ulAttrs = SFGAO_FILESYSTEM;
				lptvid->lpsfParent->GetAttributesOf(1, (const struct _ITEMIDLIST **)&lptvid->lpi, &ulAttrs);
				if (ulAttrs & (SFGAO_FILESYSTEM))
				{
					if(SHGetPathFromIDList(lptvid->lpifq,szCompare.GetBuffer(MAX_PATH)))
					{
						switch(attr)
						{
						case type_drive:
							_splitpath(szCompare,drive,dir,fname,ext);
							szCompare=drive;
							break;
						case type_folder:
							szCompare = GetItemText(treeNode);
							break;
						}
						szCompare.MakeUpper();
						if(szCompare == szSearchName)
						{
							EnsureVisible(treeNode);
							SelectItem(treeNode);
							Expand(treeNode, TVE_EXPAND);
							bRet=true;
						}
					}
				}
				lpsf2->Release();
			}
		}
		treeNode = GetNextSiblingItem(treeNode);
	}
	return bRet;
}
BOOL CMeritChangeDialog::OnInitDialog()
{
	BOOL ret = __super::OnInitDialog();
	if (!ret) return FALSE;

	// create a nice big font
	GraphStudio::MakeFont(font_filter, _T("Arial"), 12, true, false);
	label_filter.SetFont(&font_filter);
	label_filter.SetWindowText(filter_name);

	// original value
	int		idx = -1;
	int		i;

	for (i=0; i<TableMeritCount; i++) {
		if (old_merit == TableMerits[i].merit) {
			idx = i;
			break;
		}
	}

	CString		str;
	if (idx >= 0) {
		str.Format(_T("%08x (%s)"), old_merit, TableMerits[idx].name);
	} else {
		// simply format the hexadecimal code
		str.Format(_T("%08x"), old_merit);
	}
	str = str.MakeUpper();
	str = _T("0x") + str;
	edit_original.SetWindowText(str);

	// combobox
	idx = -1;
	cb_newmerit.ResetContent();
	for (i=0; i<TableMeritCount; i++) {
		str.Format(_T("%08x (%s)"), TableMerits[i].merit, TableMerits[i].name);
		str = str.MakeUpper();
		str = _T("0x") + str;
		cb_newmerit.AddString(str);
		if (TableMerits[i].merit == old_merit) {
			idx = i;
		}
	}

	if (idx >= 0) {
		cb_newmerit.SetCurSel(idx);
	} else {
		str.Format(_T("%08x"), old_merit);
		str = str.MakeUpper();
		str = _T("0x") + str;
		cb_newmerit.SetWindowText(str);
	}
	
	return TRUE;
}
Beispiel #9
0
bool Utils::IsSubstring(CString strString, CString strCheck)
{
	Utils::trim(strString);
	strString.MakeUpper();

	Utils::trim(strCheck);
	strCheck.MakeUpper();

	return (strstr(strString, strCheck) != NULL);
}
Beispiel #10
0
/**
	@brief	FindName을 찾는다.

	@author KHS	

	@date 2009-05-26 오후 3:18:13	

	@param	

	@return		
**/
bool CGridCtrlEx::FindWhatYouNeed(CString FindName, bool bMatchCase, bool bMatchWholeWord, bool bSearchDown)
{
	if(bMatchCase == false)
		FindName.MakeUpper();

	bool bContinueSearch = true;
	
	CCellID startCell = GetFocusCell();
	CCellID actCell = startCell;

	if(IsValid(actCell))
	{
		goto L_SEARCH;
	}

	do
	{
		actCell.col = 1;
		actCell.row = 1;
		for(actCell = bSearchDown ? actCell
			: GetPrevCell(actCell);
			bContinueSearch && IsValid(actCell);)
		{
			if(actCell == startCell)
			{
				bContinueSearch = false;
				break;
			}
			{
				CString rName = CGridCtrlEx::GetItemText(actCell.row, actCell.col);
				if(bMatchCase == false) rName.MakeUpper();

				if((bMatchWholeWord && rName == FindName) || (!bMatchWholeWord && (rName.Find(FindName) >= 0)))
				{
					SetSelectedRange(actCell.row, actCell.col,actCell.row, actCell.col);
					SetFocusCell(actCell);
					//!SCROL BAR MOVE
					ScrollMove(startCell, actCell);

					return true;
				}
			}

L_SEARCH:
			actCell = bSearchDown ? GetNextCell(actCell) : GetPrevCell(actCell);
		}
		if(!IsValid(actCell))
		{
			bContinueSearch = false;
		}
	}while(bContinueSearch);

	return false;	// not found
}
int CSDMdlAttrMdlNameCheck::CheckAction(void *pData, const CheckRule &checkRule, CheckResult &checkResult)
{ 
	ProMdl pMdl = (ProMdl)pData;
	if (NULL == pMdl)
	{
		checkResult.nResultType = CHECK_RESULT_INVALID_MODEL;
		return checkResult.nResultType;
	}

	if (!IsMdlTypeValid(pMdl, checkRule.dwMdlFilter))
	{
		checkResult.nResultType = CHECK_RESULT_INVALID_MODEL;
		return checkResult.nResultType;
	}

	// 检查输入值有效性
	if (checkRule.arrRuleContent.GetCount() < 2)
	{
		checkResult.nResultType = CHECK_RESULT_INVALID_INPUT;
		return checkResult.nResultType;
	}

	ProError status;
	ProName CheckedMdlName;
	status = ProMdlNameGet(pMdl,CheckedMdlName);

	CString strMdlNameCheckType;
	CString strCheckContent;
	CString strCheckedMdlName = CheckedMdlName;

	strMdlNameCheckType = checkRule.arrRuleContent[0];
	strCheckContent = checkRule.arrRuleContent[1];
	//转换成大写字母
	strCheckContent.MakeUpper();
	strCheckedMdlName.MakeUpper();

	int nIndex;
	nIndex = strCheckedMdlName.Find(strCheckContent);

	if (strMdlNameCheckType.CompareNoCase(L"包含") == 0 && nIndex != -1)
	{
		checkResult.nResultType = CHECK_RESULT_NO_ERROR;
		return CHECK_RESULT_NO_ERROR;
	}
	else if (strMdlNameCheckType.CompareNoCase(L"不包含") == 0 && nIndex == -1)
	{
		checkResult.nResultType = CHECK_RESULT_NO_ERROR;
		return CHECK_RESULT_NO_ERROR;
	}
	checkResult.nResultType = CHECK_RESULT_INVALID_VALUE;
	return CHECK_RESULT_INVALID_VALUE;
}
Beispiel #12
0
// This is called when the user clicks "Create..." on the New Project dialog
CAppWizStepDlg* CXtensnTplAppWiz::Next(CAppWizStepDlg* pDlg)
{
	ASSERT(pDlg == NULL);	// By default, this custom AppWizard has no steps

	// Set template macros based on the project name entered by the user.

	// Get value of $$root$$ (already set by AppWizard)
	CString strRoot;
	m_Dictionary.Lookup(_T("root"), strRoot);
	
	// Set value of $$Doc$$, $$DOC$$
	CString strDoc = strRoot.Left(6);
	m_Dictionary[_T("Doc")] = strDoc;
	strDoc.MakeUpper();
	m_Dictionary[_T("DOC")] = strDoc;

	// Set value of $$MAC_TYPE$$
	strRoot = strRoot.Left(4);
	int nLen = strRoot.GetLength();
	if (strRoot.GetLength() < 4)
	{
		CString strPad(_T(' '), 4 - nLen);
		strRoot += strPad;
	}
	strRoot.MakeUpper();
	m_Dictionary[_T("MAC_TYPE")] = strRoot;

// diverse Guids zum dictionary hinzufügen
	AddGuid (_T("LIBID_GUID"));
	AddGuid (_T("XTENSION_GUID"));

	AddGuid (_T("STDAFX_H_GUID"), TRUE);
	AddGuid (_T("CONFIG_H_GUID"), TRUE);
	AddGuid (_T("VERSION_H_GUID"), TRUE);
	AddGuid (_T("XTENSION_H_GUID"), TRUE);
	AddGuid (_T("XTENSIONUTIL_H_GUID"), TRUE);

// aktuelles Datum erzeugen (für VersionsInfo)
char buf[128];
time_t timeval;

	time(&timeval);
	buf[strftime(buf, sizeof(buf) - 1, "%y%m%d", localtime(&timeval))] = 0;
	m_Dictionary[_T("version_date")] = buf;

	buf[strftime(buf, sizeof(buf) - 1, "%d.%m.%Y %H:%M:%S", localtime(&timeval))] = 0;
	m_Dictionary[_T("date_n_time")] = buf;

// Return NULL to indicate there are no more steps.  (In this case, there are
//  no steps at all.)
	return NULL;
}
Beispiel #13
0
BOOL CPreStylePag::DeleteTextStyle(CString strTSName)
{
    CMObject obj, tsobj;
    long     i, nCount;
    CString  strtmp;

    //进行参数检查和初始化
    strTSName.TrimLeft();
    strTSName.TrimRight();
    strTSName.MakeUpper();
    if(strTSName.GetLength() <= 0) return FALSE;

    try
    {
        if(FindAcad() == FALSE)
        {
            return FALSE;
        }
        
        //SETUP-1: 获取ACAD文本样式列表
        obj = EDIBAcad::objAcadDoc.GetPropertyByName(
                                      _T("TextStyles"));
        
        //SETUP-2: 获取样式对象
		nCount = (long)obj.GetPropertyByName(_T("Count"));
		for( i = 0; i < nCount; i++)
		{
			tsobj = obj.Invoke(_T("Item"), 1, &_variant_t(i));
			strtmp = vtos(tsobj.GetPropertyByName(_T("Name")));
			strtmp.TrimLeft();
            strtmp.TrimRight();
			strtmp.MakeUpper();
			if(strtmp == strTSName)
			{
                //删除目标样式
                tsobj.Invoke0(_T("Delete"));
                return TRUE;
			}
		}
    }
	catch (_com_error &e)
	{
		CString strMsg;
		strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
		AfxMessageBox(strMsg);
	}
    catch(...)
    {
    }
    return FALSE;
}
Beispiel #14
0
void MyDialog4::AddRoute(unsigned int Dest, unsigned int Gate, int Metric,
						 char *Int)
{
	CString DestStr;
	CString GateStr;
	CString MetricStr;
	CString IntStr;
	int Idx;

	DestStr.Format("%d.%d.%d.%d",
		((unsigned char *)&Dest)[0], ((unsigned char *)&Dest)[1],
		((unsigned char *)&Dest)[2], ((unsigned char *)&Dest)[3]);

	GateStr.Format("%d.%d.%d.%d",
		((unsigned char *)&Gate)[0], ((unsigned char *)&Gate)[1],
		((unsigned char *)&Gate)[2], ((unsigned char *)&Gate)[3]);

	MetricStr.Format("%d", Metric);

	IntStr.Format("%c%c%c%c", Int[0], Int[1], Int[2], Int[3]);
	IntStr.MakeUpper();

	Idx = m_RoutingTable.GetItemCount();

	m_RoutingTable.InsertItem(Idx, DestStr);

	m_RoutingTable.SetItemText(Idx, 1, GateStr);
	m_RoutingTable.SetItemText(Idx, 2, MetricStr);
	m_RoutingTable.SetItemText(Idx, 3, IntStr);
}
Beispiel #15
0
bool CLicenseKey::InitFromStr(LPCTSTR szKey)
{
	CString strKey = szKey;
	if (strKey.IsEmpty())
		return false;
	
	strKey.MakeUpper();

	CString strKeyLic = strKey.Left (m_nProductKeyLen + m_nModulesKeyLen + m_nExpDateKeyLen);
	CString strParity = strKey.Mid (m_nProductKeyLen + m_nModulesKeyLen + m_nExpDateKeyLen, m_nParityKeyLen);
	
	if (CalculateParity(strKeyLic)  !=  Base36ToDec (strParity) )
		return false;
	
	long nUID = Base36ToDec (  strKeyLic.Left (m_nProductKeyLen) );
	long nModules = Base36ToDec (  strKeyLic.Mid (m_nProductKeyLen, m_nModulesKeyLen));

	DATE dtExp = DecodeExpireDate (Base36ToDec(strKeyLic.Mid (m_nProductKeyLen + m_nModulesKeyLen, m_nExpDateKeyLen)));
	if ( (long)dtExp == 0 )
		return false;

	m_nUID = nUID;
	m_nModules = nModules;
	m_dtExpiration = dtExp;
	m_strKey = strKey;

	return true;
}
//*****************************************************************************************
void CBCGPDateTimeCtrl::ChangeAmPm (UINT uiAmPm)
{
	int iDay = m_Date.GetDay ();
	int iMonth = m_Date.GetMonth ();
	int iYear = m_Date.GetYear ();
	int iHour = m_Date.GetHour ();
	int iMin = m_Date.GetMinute ();

	CString str;
	str += (char) uiAmPm;
	str.MakeUpper ();

	if (str == m_strPM [0] && iHour < 12)
	{
		iHour += 12;
	}

	if (str == m_strAM [0] && iHour >= 12)
	{
		iHour -= 12;
	}

	COleDateTime date (iYear, iMonth, iDay, iHour, iMin, 0);
	if (IsDateValid (date) && m_Date != date)
	{
		m_Date = date;
		RedrawWindow (m_rectText);

		OnDateChanged ();
	}
}
Beispiel #17
0
void CMyCommView::OnCheckSum() 
{
    m_CheckDataStyle = CDSSUM;
    m_CheckData.SetWindowText(_T("累加和"));
    CString mystr = DoGetReciveSelected();
    mystr.TrimLeft(); mystr.TrimRight();
    if (mystr == "") return;
    
    
    char data[512];
    int len=DoStr2Hex(mystr,data);
    unsigned char *ptemp=(unsigned char*)((LPCTSTR)data);
    byte a = DoCheckSum(ptemp,len);
        
    CString myvalue;
    myvalue.Format("%x",a);
    myvalue.MakeUpper();
    if (m_ReceiveValue=="") 
        m_ReceiveValue = myvalue;
    else 
        m_ReceiveValue += "\r\n" + myvalue;
    
    UpdateData(FALSE);
    if(!m_IsShowValueWindow) OnBtvisiblevalue();
    CEdit *myEdit = (CEdit *)GetDlgItem(IDC_EDRECDATAVALUE);
    myEdit->LineScroll(myEdit->GetLineCount());
}
Beispiel #18
0
void CEventModParam::OnChangeModparamsFileID()
{
	if (m_pPS) m_pPS->SetToClose(0);
	CString cString;
	m_EventModParamsFileID.GetWindowText(cString);
	bool bDoSave = false;
	//force upper
	for (int i = 0; i < cString.GetLength(); i++)
	{
		if (islower(cString[i]))
			bDoSave = true;	
		if (!isalnum(cString[i]))
		{
			cString.SetAt(i,'0');
			bDoSave = true;
		}
	}

	if (bDoSave)
	{
		cString.MakeUpper();
		m_EventModParamsFileID.SetWindowText(cString);
	}

	if (!m_bCollectingParametersForNewISO)
	{
		m_bChange = true;
		m_pApplyButton->EnableWindow(TRUE);
	}
}
void OptionIcon::Load( PlayerNumber pn, CString sText, bool bHeader )
{
	static const CString sStopWords[] = 
	{
		"1X",
		"DEFAULT",
		"OVERHEAD",
		"OFF",
	};
	
	for( unsigned i=0; i<ARRAYLEN(sStopWords); i++ )
		if( 0==stricmp(sText,sStopWords[i]) )
			sText = "";

	if( UPPERCASE )
		sText.MakeUpper();

	sText.Replace( " ", "\n" );

	bool bVacant = (sText=="");
	int iState = pn*3 + (bHeader?0:(bVacant?1:2));
	m_spr.SetState( iState );

	m_text.SetText( bHeader ? CString("") : sText );
	m_text.SetZoom( TEXT_ZOOM );
	m_text.CropToWidth( TEXT_WIDTH );
}
Beispiel #20
0
CConverter::CConverter(LPCSTR pszLibName, CFrameWnd* pWnd) : CTrackFile(pWnd)
{
	USES_CONVERSION;
	m_hBuff = NULL;
	m_pBuf = NULL;
	m_nBytesAvail = 0;
	m_nBytesWritten = 0;
	m_nPercent = 0;
	m_hEventFile = NULL;
	m_hEventConv = NULL;
	m_bDone = TRUE;
	m_bConvErr = FALSE;
	m_hFileName = NULL;
	OFSTRUCT ofs;
	if (OpenFile(pszLibName, &ofs, OF_EXIST) == HFILE_ERROR)
	{
		m_hLibCnv = NULL;
		return;
	}
	m_hLibCnv = LoadLibraryA(pszLibName);
	if (m_hLibCnv < (HINSTANCE)HINSTANCE_ERROR)
		m_hLibCnv = NULL;
	else
	{
		LoadFunctions();
		ASSERT(m_pInitConverter != NULL);
		if (m_pInitConverter != NULL)
		{
			CString str = AfxGetAppName();
			str.MakeUpper();
			VERIFY(m_pInitConverter(AfxGetMainWnd()->GetSafeHwnd(), T2CA(str)));
		}
	}
}
Beispiel #21
0
////////////////////////////////////////////////////////////////////////
// IsGoodKey
//
bool CKeyRegistry::IsGoodKey()
{
	CString sName = GetName();
    int  length   = sName.GetLength();
	WORD result   = (WORD) GetKey();

	if (IsTemporaryKey())
	{
		time_t time = 0;
		DWORD dwValue = GetValue("key", 0);

		if (dwValue == 0)
			return true;

		CTime date((time_t)dwValue);

		int days = abs((CTime::GetCurrentTime() - date).GetDays());

		if (days > 15)
			return true;
	}

	sName.MakeUpper();

    for (int i = 0; i < length; i++)
      result -= (((WORD)sName[i]) << ((i + 3) % 7));

	return true;//(result == 0xFADE && length > 2);
}
Beispiel #22
0
int match_string(CString &line, CString token, int indent, int error)
{
  int maxi, maxj;
  int i,j;

  maxi=line.GetLength();
  if(!maxi) return 0;
  maxj=token.GetLength();
  i=0;
  j=0;
  while(j<maxj)
  {
    if(token[j]=='%')
    {
      switch(token[++j])
      {
      case 'd': //number
        if(i>=maxi) return error;
        while((i<maxi) && (line[i]>='0') && (line[i]<='9') ) i++;
        break;
      }
      j++;
      continue;
    }
    if(i>=maxi) return error;           //end of line without full parse
    if(toupper(line[i])!=token[j]) return error; //difference
    i++;
    j++;
  }
  if(i<maxi) return error;              //excess on line
  line.MakeUpper();
  line=CString(TCHAR(' '),indent)+line;
  return 0;
}
Beispiel #23
0
CString byte2str(byte *bytes, int len)
{
	int 	pos = 0;
	CString ret;
	char 	pBuffer[100];

	for(int n = 0; n < len; n ++)
	{
		_itoa(bytes[n], pBuffer, 16);

		if(bytes[n] < 16)
		{
			ret.Insert(pos, "0");
			pos++;
			ret.Insert(pos, pBuffer);
			pos++;
		}
		else
		{
			ret.Insert(pos, pBuffer);
			pos+=2;
		}
	}

	ret.MakeUpper();
	return ret;
}
Beispiel #24
0
CString GetIPAddress()
{
	WORD wVersionRequested;
    WSADATA wsaData;
    char name[255];
    CString IP;
	PHOSTENT hostinfo;
	wVersionRequested = MAKEWORD(2,0);
	
	if (WSAStartup(wVersionRequested, &wsaData)==0)
	{
		if(gethostname(name, sizeof(name))==0)
		{
			if((hostinfo=gethostbyname(name)) != NULL)
			{
				IP = inet_ntoa(*(struct in_addr*)* hostinfo->h_addr_list);
			}
		}
		
		WSACleanup();
	} 
	IP.MakeUpper();

	return IP;
}
Beispiel #25
0
void CSequence::DeriveName()
{
	if (m_path == NULL)
	{
		if (m_name != NULL)
		{
			free(m_name);
			m_name = NULL;
		}
		return;
	}
	CString name = m_path;
	int loc = name.ReverseFind('.');
	if (loc > -1)
	{
		name = name.Left(loc);
	}
	loc = name.ReverseFind('/');
	if (loc > -1)
	{
		name = name.Right(name.GetLength() - loc - 1);
	}
	name.MakeUpper();
	SetName(name);
}
Beispiel #26
0
//##ModelId=474D304F0158
BOOL CGetSetOptions::SetListToPutOnClipboard(CString cs)	
{ 
	cs.MakeUpper();
	m_csIPListToPutOnClipboard = cs;
	return SetProfileString("ListToPutOnClipboard", cs); 

}
Beispiel #27
0
BOOL CResizableLayout::LikesClipping(HWND hWnd)
{
	// check child type
	CString st;
	GetClassName(hWnd, st.GetBufferSetLength(MAX_PATH), MAX_PATH);
	st.ReleaseBuffer();
	st.MakeUpper();

	DWORD style = GetWindowLong(hWnd, GWL_STYLE);

	// skip windows that wants background repainted
	if (st == "BUTTON" && (style & 0x0FL) == BS_GROUPBOX)
		return FALSE;
	if (st == "STATIC")
	{
		switch (style & SS_TYPEMASK)
		{
		case SS_BLACKRECT:
		case SS_GRAYRECT:
		case SS_WHITERECT:
		case SS_ETCHEDHORZ:
		case SS_ETCHEDVERT:
			break;
		case SS_ICON:
		case SS_ENHMETAFILE:
			if (style & SS_CENTERIMAGE)
				return FALSE;
			break;
		default:
			return FALSE;
		}
	}
	return TRUE;
}
BOOL CFileBasedProjectTemplateItem::InitItem(LPCTSTR lpszPath, CImageList &ImageList32, CImageList &ImageList16)
{
	m_strPath = lpszPath;

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	//extract description, if available
	CTextSourceFile TextFile;
	if (TextFile.Create(lpszPath))
	{
		LPCTSTR lpLine;
		int nLength;
		if (TextFile.GetNextLine(lpLine, nLength))
		{
			CString strLine(lpLine, nLength);
			CString strKey(_T("%DESCRIPTION: "));
			CString strStartOfLine = strLine.Left(strKey.GetLength());
			strStartOfLine.MakeUpper();

			if (strStartOfLine == strKey)
				m_strDescription = strLine.Right(strLine.GetLength() - strKey.GetLength());
		}
	}

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	//generate title
	m_strTitle = CPathTool::GetFileTitle(m_strPath);

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	//add image to image list and remember index
	HICON hIcon = theApp.LoadIcon(IDR_LATEXDOCTYPE);
	m_nImageIndex = hIcon ? ImageList32.Add(hIcon) : -1;
	ImageList16.Add(hIcon);

	return TRUE;
}
Beispiel #29
0
// 将pc中的文件夹从一个目录拷贝到另外的一个目录
BOOL MoveDirectory(CString strSrcPath, CString strDesPath)
{
	if( strSrcPath.IsEmpty() )
	{       
		return FALSE;
	}

	if ( !PathIsDirectory(strDesPath) )
	{
		if ( !CreateDirectory(strDesPath,NULL))
			return FALSE;
	}

	if ( strSrcPath.GetAt(strSrcPath.GetLength()-1) != '\\' )
		strSrcPath += '\\';
	if ( strDesPath.GetAt(strDesPath.GetLength()-1) != '\\' )
		strDesPath += '\\';

	BOOL bRet = FALSE; // 因为源目录不可能为空,所以该值一定会被修改
	CFileFind ff;  
	BOOL bFound = ff.FindFile(strSrcPath+_T("*"),   0);  
	CString strFile;
	BOOL bSpecialFile=FALSE;
	while(bFound)      // 递归拷贝
	{  
		bFound = ff.FindNextFile();  
		bSpecialFile=FALSE;
		if( ff.IsDots() )  
			continue;

		CString strSubSrcPath = ff.GetFilePath();
		CString strSubDespath = strSubSrcPath;
		strSubDespath.Replace(strSrcPath, strDesPath);

		if( ff.IsDirectory() )
			bRet = MoveDirectory(strSubSrcPath, strSubDespath);     // 递归拷贝文件夹
		else
		{
			strFile=PathFindFileName(strSubSrcPath);
			strFile.MakeUpper();
			for (int i=0;i<nSpecialFileCount;i++)
			{
				//找到特殊文件
				if(_tcscmp(strFile.GetString(),sSpecialFile[i])==0)
				{
					bSpecialFile=TRUE;
					break;
				}	
			}
			if(bSpecialFile)
				bRet=MoveFileEx( strSubSrcPath,strSubDespath,MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
			else
				bRet = MoveFileEx(strSubSrcPath, strSubDespath,MOVEFILE_REPLACE_EXISTING);   // 移动文件
		}
		if ( !bRet )
			break;
	}  
	ff.Close();
	return bRet;
}
Beispiel #30
0
//截取Section
void CINIsoc::CutString(char* fid, int len, CString& sFile)
{
	char *pline_head = fid;
	int readtotal = 0;
	//纳入内存池,从缓存中申请,更快
	char* buf = theApp.m_memPool.NewMem(KEY_BUF);
	if(NULL==buf)
		return;
	memset(buf,0,KEY_BUF);
	DWORD wRet = 0;
	for(int i=0;i<len;i++)
	{
		if(fid[i] == 0x0)
		{
			CString str ;
			str.Format("%s",pline_head);
			//截取Section中的keys
			wRet = 0;
			wRet = ::GetPrivateProfileSection(str,buf,KEY_BUF,sFile);//某个section的所有内容
			if(wRet > 0){
				ATF_MAP atf_map;
				CutString(buf,wRet,atf_map);
				str.MakeUpper(); //统一大写 2011.10.17
				//插入节点
				m_SectMap.insert( SECT_PAIRMAP( str, atf_map ) );
			}
			if(fid[i+1] == 0x0)
				break;//字段结束;
			pline_head = fid+i+1;
		}
	}
	//纳入内存池
	theApp.m_memPool.FreeMem(buf);
}