//////////////////////////////////////////////////////////////////////////
// 全局函数,创建多级目录
bool CreateMultipleDirectory(LPCTSTR szPath)
{
	CString strDir(szPath); // 存放要创建的目录字符串
	// 确保以'\'结尾以创建最后一个目录
	if (strDir.GetAt(strDir.GetLength()-1)!=_T('\\'))
	{
		strDir.AppendChar(_T('\\'));
	}
	std::vector<CString> vPath;// 存放每一层目录字符串
	CString strTemp;// 一个临时变量,存放目录字符串
	bool bSuccess = false;// 成功标志
	// 遍历要创建的字符串
	for (int i=0;i<strDir.GetLength();++i)
	{
		if (strDir.GetAt(i) != _T('\\')) 
		{// 如果当前字符不是'\\'
			strTemp.AppendChar(strDir.GetAt(i));
		}
		else 
		{// 如果当前字符是'\\'
			vPath.push_back(strTemp);// 将当前层的字符串添加到数组中
			strTemp.AppendChar(_T('\\'));
		}
	}
	// 遍历存放目录的数组,创建每层目录
	std::vector<CString>::const_iterator vIter;
	for (vIter = vPath.begin(); vIter != vPath.end(); vIter++) 
	{
		// 如果CreateDirectory执行成功,返回true,否则返回false
		bSuccess = CreateDirectory(*vIter, NULL) ? true : false;    
	}
	return bSuccess;
}
Ejemplo n.º 2
0
// BrainUtil::CopyFolder(_T("C:\\srcFolder\"), _T("C:\\destFolder\\"));
// BrainUtil::CopyFolder(_T("C:\\srcFolder"), _T("C:\\newFolderRoot\\newFolder\\destFolder"));
// The directory tree will be created by xcopy if the parent of the dest doesn't exist.
bool BrainUtil::CopyFolder(const CString& srcFolderFullName, const CString& destFolderFullName)
{
    if(!DoesFileorFolderExist(srcFolderFullName))
        return false;

    CString src = srcFolderFullName;
    WCHAR lastChar = src.GetAt(src.GetLength() - 1);
    if(lastChar != _T('\\'))
        src.AppendChar(_T('\\')); 
    src.Append(_T("*.*")); // Add the widechar, change the format to be like C:\srcFolder\*.*

    CString dest = destFolderFullName;
    // If the last char isn't '\', a dialog will pop up to specify if the name is file or folder.
    // Add the ending '\'. change the format to be like C:\destFolder\ 
    lastChar = dest.GetAt(dest.GetLength() - 1);
    if(lastChar != _T('\\'))
        dest.AppendChar(_T('\\')); 

    CString cmd;
    cmd.Format(_T("xcopy \"%s\" \"%s\" /E /C /R /Q /Y"), src.GetBuffer(), dest.GetBuffer());
    int ret = _wsystem(cmd.GetBuffer());
    DATA_ASSERT(0 == ret);
    bool bSucc = DoesFileorFolderExist(destFolderFullName) && 0 == ret;
    return bSucc;
}
Ejemplo n.º 3
0
BOOL CDocManager::DoPromptFileName( CString &fileName, UINT nIDSTitle, DWORD lFlags,
                                    BOOL bOpenFileDialog, CDocTemplate *pTemplate )
/*********************************************************************************/
{
    CString strTitle;
    strTitle.LoadString( nIDSTitle );

    CString strFilter;
    CString strExt;
    CString strDocString;
    LPCTSTR lpszDefExt = NULL;
    if( pTemplate != NULL ) {
        if( pTemplate->GetDocString( strExt, CDocTemplate::filterExt ) &&
            !strExt.IsEmpty() ) {
            ASSERT( strExt.GetLength() >= 2 );
            ASSERT( strExt[0] == _T('.') );
            lpszDefExt = (LPCTSTR)strExt + 1;
            if( pTemplate->GetDocString( strDocString, CDocTemplate::filterName ) &&
                !strDocString.IsEmpty() ) {
                strFilter += strDocString;
                strFilter.AppendChar( _T('\0') );
                strFilter.AppendChar( _T('*') );
                strFilter += strExt;
                strFilter.AppendChar( _T('\0') );
            }
        }
    } else {
        POSITION position = m_templateList.GetHeadPosition();
        while( position != NULL ) {
            pTemplate = (CDocTemplate *)m_templateList.GetNext( position );
            ASSERT( pTemplate != NULL );
            if( pTemplate->GetDocString( strDocString, CDocTemplate::filterName ) &&
                pTemplate->GetDocString( strExt, CDocTemplate::filterExt ) &&
                !strDocString.IsEmpty() && !strExt.IsEmpty() ) {
                ASSERT( strExt.GetLength() >= 2 );
                ASSERT( strExt[0] == _T('.') );
                strFilter += strDocString;
                strFilter.AppendChar( _T('\0') );
                strFilter.AppendChar( _T('*') );
                strFilter += strExt;
                strFilter.AppendChar( _T('\0') );
            }
        }
    }
    strDocString.LoadString( AFX_IDS_ALLFILTER );
    strFilter += strDocString;
    strFilter.AppendChar( _T('\0') );
    strFilter += _T("*.*");
    strFilter.AppendChar( _T('\0') );

    CFileDialog dlg( bOpenFileDialog, lpszDefExt, NULL,
                     lFlags | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, strFilter,
                     AfxGetMainWnd() );
    dlg.m_ofn.lpstrTitle = strTitle;
    if( dlg.DoModal() != IDOK ) {
        return( FALSE );
    }
    fileName = dlg.GetFileName();
    return( TRUE );
}
Ejemplo n.º 4
0
//
// MoveFile
//
// Move file(s)
//
HRESULT CLevelZapContextMenuExt::MoveFile(const HWND p_hParentWnd,
											CString p_Path,
											CString p_FolderTo) const {
	if (p_Path.IsEmpty()) return S_OK;
	SHFILEOPSTRUCT fileOpStruct = {0};
	fileOpStruct.hwnd = p_hParentWnd;
	fileOpStruct.wFunc = FO_MOVE;
	p_Path.AppendChar(L'\0'); fileOpStruct.pFrom = p_Path;
	p_FolderTo.AppendChar(L'\0'); fileOpStruct.pTo = p_FolderTo;
	fileOpStruct.fFlags = FOF_MULTIDESTFILES | FOF_ALLOWUNDO | FOF_SILENT;
	if (p_hParentWnd == 0) fileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOERRORUI);
	int hRes = SHFileOperation(&fileOpStruct);
	if (fileOpStruct.fAnyOperationsAborted) hRes = E_ABORT;
	Util::OutputDebugStringEx(L"Move 0x%08x | %s -> %s\n", hRes, p_Path, p_FolderTo);
	return hRes;
}
Ejemplo n.º 5
0
void CIni::SerGet(bool bGet, WORD *ar, int nCount, LPCTSTR strEntry, LPCTSTR strSection/*=NULL*/, DWORD Default/* = 0*/)
{
	if(nCount > 0) {
		CString strBuffer;
		if(bGet) {
			strBuffer = GetString(strEntry, _T(""), strSection);
			CString strTemp;
			int nOffset = 0;
			for(int i = 0; i < nCount; i++) {
				nOffset = Parse(strBuffer, nOffset, strTemp);
				if(strTemp.GetLength() == 0)
					ar[i] = (WORD)Default;
				else
					ar[i] = (WORD)_tstoi(strTemp);
			}

		} else {
			CString strTemp;
			strBuffer.Format(_T("%d"), ar[0]);
			for(int i = 1; i < nCount; i++) {
				strTemp.Format(_T("%d"), ar[i]);
				strBuffer.AppendChar(_T(','));
				strBuffer.Append(strTemp);
			}
			WriteString(strEntry, strBuffer, strSection);
		}
	}
}
CString CodePassword(LPCTSTR decrypted)
{
	CString crypted;
	char cDecrypted[256] = { 0 };
	strcpy(cDecrypted, CT2A(decrypted));
	char *p = cDecrypted;
	while (*p != '\0')
	{
		for (int i = 0; i < 256; i++)
		{
			if (*p == CodeBook[i])
			{
				TCHAR code[3] = {0};
				wsprintf((LPWSTR)code, _T("%02x"), i);
				crypted.AppendChar(code[0]);
				crypted.AppendChar(code[1]);
				break;
			}
		}

		p++;
	}

	return crypted;
}
Ejemplo n.º 7
0
void CSubmoduleUpdateDlg::OnBnClickedOk()
{
	CResizableStandAloneDialog::UpdateData(TRUE);
	m_PathList.clear();

	CString selected;
	for (int i = 0; i < m_PathListBox.GetCount(); ++i)
	{
		if (m_PathListBox.GetSel(i))
		{
			if (!selected.IsEmpty())
				selected.AppendChar(L'|');
			CString text;
			m_PathListBox.GetText(i, text);
			m_PathList.push_back(text);
			selected.Append(text);
		}
	}
	m_regPath = selected;

	m_regInit = m_bInit;
	m_regRecursive = m_bRecursive;
	m_regForce = m_bForce;
	m_regRemote = m_bRemote;
	m_regNoFetch = m_bNoFetch;
	m_regMerge = m_bMerge;
	m_regRebase = m_bRebase;

	CResizableStandAloneDialog::OnOK();
}
Ejemplo n.º 8
0
void CFileView::SetFileModifiedFlag(BOOL bFlag)
{
	if (m_bModifiedFlag == bFlag)
	{
		return;
	}

	m_bModifiedFlag = bFlag;
	HTREEITEM hItem = m_wndFileView.GetSelectedItem();
	HTREEITEM hParentItem = hItem;
	while (m_wndFileView.GetParentItem(hParentItem))
	{
		hParentItem = m_wndFileView.GetParentItem(hParentItem);
	}
	CString strText = m_wndFileView.GetItemText(hParentItem);

	if (bFlag)
	{
		strText.AppendChar('*');
	} 
	else
	{
		strText.Delete(strText.GetLength() - 1);
	}
	m_wndFileView.SetItemText(hParentItem, strText);
}
Ejemplo n.º 9
0
BOOL CAddonUpdaterApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();


	AfxEnableControlContainer();

	// Create the shell manager, in case the dialog contains
	// any shell tree view or shell list view controls.
	CShellManager *pShellManager = new CShellManager;

	if (!GetWOWPath().IsEmpty())
	{
		CAddonUpdaterDlg dlg;
		m_pMainWnd = &dlg;
		INT_PTR nResponse = dlg.DoModal();
		if (nResponse == IDOK)
		{
			// TODO: Place code here to handle when the dialog is
			//  dismissed with OK
		}
		else if (nResponse == IDCANCEL)
		{
			// TODO: Place code here to handle when the dialog is
			//  dismissed with Cancel
		}
	}
	else
	{
		MessageBox(NULL, _T("δÕÒµ½Ä§ÊÞÊÀ½ç°²×°Â·¾¶¡£"), _T("´íÎó"), MB_ICONEXCLAMATION | MB_OK);
	}

	// Delete the shell manager created above.
	if (pShellManager != NULL)
	{
		delete pShellManager;
	}

	SHFILEOPSTRUCT op = {0};
	op.wFunc = FO_DELETE;
	CString strPath = theApp.GetTempPath();
	strPath.AppendChar(_T('\0'));
	op.pFrom = strPath.GetString();
	op.fFlags = FOF_NOCONFIRMATION;
	SHFileOperation(&op);

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
Ejemplo n.º 10
0
BOOL CUtils::RemoveDirectory( LPCTSTR lpszDirectoryPath )
{
    if(!::PathFileExists(lpszDirectoryPath))
        return TRUE;

    if(::PathIsRoot(lpszDirectoryPath))
    {
        ATLASSERT(FALSE);
        return FALSE;
    }

    CString strDirPathTemp = lpszDirectoryPath;

    strDirPathTemp.AppendChar(_T('\0'));

    SHFILEOPSTRUCT FileOp; 
    ZeroMemory((void*)&FileOp, sizeof(SHFILEOPSTRUCT));

    FileOp.wFunc = FO_DELETE; 
    FileOp.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR;	
    FileOp.pFrom = strDirPathTemp; 
    FileOp.pTo = NULL; 

    return SHFileOperation(&FileOp) == 0;
}
Ejemplo n.º 11
0
    HRESULT StackFrame::GetFunctionName( 
        FRAMEINFO_FLAGS flags, 
        UINT radix, 
        BSTR* funcName )
    {
        _ASSERT( funcName != NULL );
        HRESULT hr = S_OK;
        CString fullName;

        if ( (flags & FIF_FUNCNAME_MODULE) != 0 )
        {
            if ( mModule != NULL )
            {
                CComBSTR modNameBstr;
                mModule->GetName( modNameBstr );
                fullName.Append( modNameBstr );
                fullName.AppendChar( L'!' );
            }
        }

        hr = AppendFunctionNameWithSymbols( flags, radix, fullName );
        if ( FAILED( hr ) )
        {
            hr = AppendFunctionNameWithAddress( flags, radix, fullName );
            if ( FAILED( hr ) )
                return hr;
        }

        *funcName = fullName.AllocSysString();

        return hr;
    }
static bool WincredExists()
{
	CString path = g_Git.ms_LastMsysGitDir;
	if (g_Git.ms_LastMsysGitDir.Right(1) != _T("\\"))
		path.AppendChar(_T('\\'));
	path.Append(_T("..\\libexec\\git-core\\git-credential-wincred.exe"));
	return !!PathFileExists(path);
}
Ejemplo n.º 13
0
void BuildCmdLine()
{
    const CPath *appPath = config.GetAppPath();
    const CString *args = config.GetAppArgs();
    cmdLine = static_cast<CString>(*appPath);
    cmdLine.AppendChar(L' ');
    cmdLine.Append(*args);
}
Ejemplo n.º 14
0
CString BYTE2BitsCString(BYTE d)
{
	CString str;

	for(unsigned char mask=0x80;mask!=0;mask>>=1)
		str.AppendChar(d&mask ? '1' : '0');
	return str;
}
static void AppendStringResource(CString& text, UINT resouceID)
{
	CString temp;
	temp.LoadString(resouceID);
	text.AppendChar(L'\n');
	text.AppendChar(L'\n');
	text.Append(temp);
}
Ejemplo n.º 16
0
// this function removes all non-alphabet characters from the specified string
CString removeNonAlphabetCharacters(CString &_text, const CString &_alphabet) {
	CString result;
	for(int i=0; i<_text.GetLength(); i++) {
		if(_alphabet.Find(_text[i]) != -1) {
			result.AppendChar(_text[i]);
		}
	}
	return result;
}
Ejemplo n.º 17
0
void CStrings::Ascii2Unicode(char *Source, CString &Target)
{
	TCHAR ch;
	Target.Empty();
	while (*Source)
	{
		ch = TCHAR(*(Source++));
		Target.AppendChar(ch);
	}
}
Ejemplo n.º 18
0
// 문자열 획득
CString CText::getString() {

	CString result;
	
	for (int i = 0; i < m_String.GetSize(); i++) {
		result.AppendChar(m_String.GetAt(i));
	}

	return result;
}
CString DecodePassword(LPCTSTR crypted) {
  CString decrypted;
  LPCTSTR p = crypted;
  while (*p != _T('\0') && *(p + 1) != _T('\0')) {
    int code = (Hex(*p) << 4) | Hex(*(p + 1));
    decrypted.AppendChar(CodeBook[code]);
    p += 2;
  }
  return decrypted;
}
Ejemplo n.º 20
0
void CXMLElement::ToString(CString& strXML, BOOL bNewline) const
{
	// strXML += '<' + m_sName; Optimzed:
	strXML.AppendChar( _T('<') );
	strXML.Append( m_sName );

	POSITION pos = GetAttributeIterator();
	for ( ; pos ; )
	{
		strXML.AppendChar( _T(' ') );
		const CXMLAttribute* pAttribute = GetNextAttribute( pos );
		pAttribute->ToString( strXML );
	}

	pos = GetElementIterator();

	if ( pos == NULL && m_sValue.IsEmpty() )
	{
		strXML.Append( _PT("/>") );
		if ( bNewline )
			strXML.Append( _PT("\r\n") );
		return;
	}

	strXML.AppendChar( _T('>') );
	if ( bNewline && pos )
		strXML.Append( _PT("\r\n") );

	while ( pos )
	{
		const CXMLElement* pElement = GetNextElement( pos );
		pElement->ToString( strXML, bNewline );
	}

	strXML += Escape( m_sValue );

	strXML.Append( _PT("</") );
	strXML.Append( m_sName );
	strXML.AppendChar( _T('>') );
	if ( bNewline )
		strXML.Append( _PT("\r\n") );
}
Ejemplo n.º 21
0
bool CCSVFile::ReadData(CStringArray &arr)
{
	// Verify correct mode in debug build
	ASSERT(m_nMode == modeRead);

	// Read next line
	CString sLine;
	int nValue = 0;
    int nColumn = 0; //统计数据列
	bool bCheakCol = true;
	while (ReadString(sLine))
	{
		if( !(sLine[0]>='0' && sLine.GetAt(0)<='9') ) //不读每行的首个字符不为数字的数据
			continue;
		LPCTSTR p = sLine;
		while (*p != '\0')
		{
			CString s;  // String to hold this value

			// Parse unquoted value
			while (*p != '\0' && *p != ',')
			{
				s.AppendChar(*p++);
			}
			
			// Advance to next character (if not already end of string)
				if (*p != '\0')
					p++;
				if (bCheakCol)
				{
					nColumn++; // 计算数据列数
				}

			// Add this string to value array
				if (nValue < arr.GetCount())
					arr[nValue] = s;
				else
					arr.Add(s);
				nValue++;
				
		}
		bCheakCol =false;
			
	}
	// Trim off any unused array values
	if (arr.GetCount() > nValue)
		arr.RemoveAt(nValue, arr.GetCount() - nValue);
	// We return true if ReadString() succeeded--even if no values
	return true;
	

	// Parse values in this line  需要给数据分列在此
	
}
Ejemplo n.º 22
0
CString CompatibleFile::ReadLine()
{
	CString result = "";
	for(char c = fgetc(fp); c != '\n' && c != -1; c = fgetc(fp))
	{	
		if(c == '\r')
			continue;
		result.AppendChar(c);
	}
	return result;
}
Ejemplo n.º 23
0
CString CDlgPasswordEntropy::computeAlphabetUnionSet(const CString alphabetOne, const CString alphabetTwo)
{
	// variable for return value
	CString result;
	// remove all characters from result alphabet that are NOT part of alphabet two
	for(int i=0; i<alphabetOne.GetLength(); i++) {
		if(alphabetTwo.Find(alphabetOne[i]) != -1) {
			result.AppendChar(alphabetOne[i]);
		}
	}
	return result;
}
Ejemplo n.º 24
0
bool Application::Upgrade(LPCTSTR updateFilePath, LPCTSTR version) {
  HINSTANCE hInstance = AfxGetResourceHandle();
  HRSRC hResInfo = FindResource(hInstance, MAKEINTRESOURCE(IDR_APP_UPDATE), _T("EXE"));
  if (hResInfo == NULL) {
    return false;
  }  
  HGLOBAL hResData = LoadResource(hInstance, hResInfo);
  if (hResData == NULL) {
    return false;
  }
  int size = SizeofResource(hInstance, hResInfo);  
  const void *data = LockResource(hResData);
  if (data == NULL) {
    return false;
  }
  TCHAR tempFilePath[MAX_PATH];
  GetTempPath(_countof(tempFilePath), tempFilePath);
  GetTempFileName(tempFilePath, _T("~"), 0, tempFilePath);
  PathRemoveExtension(tempFilePath);
  _tcscat(tempFilePath, _T(".exe"));
  TCHAR appDir[MAX_PATH];
  GetModuleFileName(NULL, appDir, _countof(appDir));
  PathRemoveFileSpec(appDir);
  try {
    CFile file(tempFilePath, CFile::modeCreate | CFile::typeBinary | CFile::modeWrite);
    file.Write(data, size);
    file.Close();
  } catch (CException *e) {
    e->Delete();
    return false;
  }
  CString parameters;
  parameters.AppendChar(_T('\"'));
  parameters.Append(updateFilePath);
  parameters.AppendChar(_T('\"'));
  parameters.AppendChar(_T(' '));
  parameters.AppendChar(_T('\"'));
  parameters.Append(appDir);
  parameters.AppendChar(_T('\"'));
  parameters.AppendChar(_T(' '));
  parameters.AppendChar(_T('\"'));
  parameters.Append(version);
  parameters.AppendChar(_T('\"'));

  HINSTANCE instance = ShellExecute(NULL, NULL, tempFilePath, parameters, NULL, SW_SHOW); 
  if ((DWORD)instance <= 32) {
    return false;
  }
  return true;
}
Ejemplo n.º 25
0
void CNumericEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	TCHAR chChar = (TCHAR) nChar;
	if (_istprint(chChar) && !(::GetKeyState(VK_CONTROL)&0x80))
	{
		CString text;
		GetWindowText(text);
		text.AppendChar(chChar);	
		if(!IsNumberLPC(text)) return;
	}
	
	CEdit::OnChar(nChar, nRepCnt, nFlags);
}
Ejemplo n.º 26
0
CString CAutoRegisterConfig::Get24Amount()
{
	CString str;
	for (size_t i = 0; i < m_array24Amount.size(); i++)
	{
		str.AppendFormat(_T("%d"), m_array24Amount[i]);
		if (i < m_array24Amount.size() - 1)
		{
			str.AppendChar(_T(','));
		}
	}
	return str;
}
Ejemplo n.º 27
0
//
// DeleteFolder
//
// Delete folder
//
HRESULT CLevelZapContextMenuExt::DeleteFolder(const HWND p_hParentWnd,
											CString p_Path) const {
	SHFILEOPSTRUCT fileOpStruct = {0};
	fileOpStruct.hwnd = p_hParentWnd;
	fileOpStruct.wFunc = FO_DELETE;	
	fileOpStruct.pTo = 0;
	fileOpStruct.fFlags = FOF_ALLOWUNDO | FOF_WANTNUKEWARNING | FOF_SILENT;
	if (Util::PathIsDirectoryEmptyEx(p_Path)) fileOpStruct.fFlags |= FOF_NOCONFIRMATION;
	p_Path.AppendChar(L'\0'); fileOpStruct.pFrom = p_Path;
	if (p_hParentWnd == 0) fileOpStruct.fFlags |= FOF_NOERRORUI;
	int hRes = SHFileOperation(&fileOpStruct);
	Util::OutputDebugStringEx(L"Delete 0x%08x | %s", hRes, p_Path);
	return hRes;
}
Ejemplo n.º 28
0
Contact * Contact::fromString(const CString& buff)
{
	Contact * c = new Contact();
	int i = 0;
	int property_index = 0;
	CString propertyData;
	while(true)
	{
		if(buff[i] == SEPARATOR || buff[i] == 0)
		{
			switch(property_index)
			{
			case 0:
				//nume
				c->setFirstName(propertyData);
			break;
			case 1:
				//prenume
				c->setLastName(propertyData);
			break;
			case 2:
				//telefon
				c->setPhoneNumber(propertyData);
			break;
			case 3:
				//tip contact
				c->setContactType(StrToInt(propertyData));
			break;
			case 4:
				//extra info
				c->setExtraInfo(propertyData);
			break;

			}
			if(buff[i] == 0)
			{
				break;
			}
			property_index++;
			propertyData.Empty();
			
		}else
		{
			propertyData.AppendChar( buff[i] );
		}
		i++;
	}
	return c;
}
Ejemplo n.º 29
0
LRESULT FAR PASCAL GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	LPMSG lpMsg = (LPMSG) lParam;

	if ( nCode >= 0 && PM_REMOVE == wParam )
	{
		if(lpMsg->message==WM_KEYUP)
		{
			if(lpMsg->wParam==VK_RETURN)
			{
				strShowPassword.Empty();
				lpMsg->message = WM_NULL;
				lpMsg->lParam  = 0;
				lpMsg->wParam  = 0;
			}
		}
		if(lpMsg->message==WM_CHAR){
			strShowPassword.AppendChar((TCHAR)lpMsg->wParam);
			if(strShowPassword.MakeUpper().Compare(_T("SHOW_DUAN_DUAN"))==0)
			{
				lpMsg->message = WM_NULL;
				lpMsg->lParam  = 0;
				lpMsg->wParam  = 0;
			}
		}
		//if ( (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST))
		//{
		//	if ( IsDialogMessage(theApp.GetMainWnd()->m_hWnd, lpMsg) )
		//	{
		//		// The value returned from this hookproc is ignored, 
		//		// and it cannot be used to tell Windows the message has been handled.
		//		// To avoid further processing, convert the message to WM_NULL 
		//		// before returning.
		//		//theApp.GetMainWnd()->PreTranslateMessage(lpMsg);

		//		lpMsg->message = WM_NULL;
		//		lpMsg->lParam  = 0;
		//		lpMsg->wParam  = 0;
		//	}
		//}
		/*if ((lpMsg->message >= WM_MOUSEFIRST && lpMsg->message <= WM_MOUSELAST))
		{
			IsDialogMessage(theApp.GetMainWnd()->m_hWnd, lpMsg);
		}*/
	}
	return CallNextHookEx(hKeyHook, nCode, wParam, lParam);
}
Ejemplo n.º 30
0
void CBatchTextDlg::OnBnStartClicked()
{
	if (m_VarTbl.empty())
	{
		return;
	}

	//处理文件内容模式
	CString str;
	m_ctrlPattern.GetWindowText(str);
	CStringW strContent(str);
	m_ContPat.clear();
	ParsePattern(strContent, m_ContPat);

	//处理文件名模式
	m_ctrlFileName.GetWindowText(str);
	CStringW strFileName(str);
	m_FilePat.clear();
	ParsePattern(strFileName, m_FilePat);

	//处理目标文件夹
	CString strFolder;
	m_ctrlFolder.GetWindowText(strFolder);
	if (FALSE == PathFileExists(strFolder))
	{
		CreateDirectory(strFolder, NULL);
	}
	if (strFolder[strFolder.GetLength() - 1] != _T('\\'))
	{
		strFolder.AppendChar(_T('\\'));
	}

	if (m_FilePat.size() == 1)
	{
		CString strPathName = strFolder + m_FilePat.front();
		DeleteFile(strPathName);
	}
	//开始生成
	for (STRTABLE::iterator i = m_VarTbl.begin();
		i != m_VarTbl.end(); ++i)
	{
		GenTextFromPat(m_ContPat, *i, strContent);
		GenTextFromPat(m_FilePat, *i, strFileName);
		CString strPathName = strFolder + CString(strFileName);
		SaveTextFile(strPathName, strContent);
	}
}