Click here to Skip to main content
15,914,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to get Rect value ????? HELP !!!! Pin
Member 143833713-Mar-05 6:58
Member 143833713-Mar-05 6:58 
GeneralRe: How to get Rect value ????? HELP !!!! Pin
JohnCz18-Mar-05 10:53
JohnCz18-Mar-05 10:53 
AnswerRe: How to get Rect value ????? HELP !!!! Pin
Member 143833713-Mar-05 11:22
Member 143833713-Mar-05 11:22 
AnswerRe: How to get Rect value ????? HELP !!!! Pin
Maximilien13-Mar-05 13:11
Maximilien13-Mar-05 13:11 
QuestionHow can I detect a CODEC was installed? And detect its version. Pin
Behzad Ebrahimi13-Mar-05 5:00
Behzad Ebrahimi13-Mar-05 5:00 
General[Q]: Number of overloaded functions... Pin
rbid13-Mar-05 4:40
rbid13-Mar-05 4:40 
GeneralRe: [Q]: Number of overloaded functions... Pin
David Crow14-Mar-05 3:30
David Crow14-Mar-05 3:30 
GeneralGNU diff.exe this code ins't working :( Pin
YaronNir13-Mar-05 4:05
YaronNir13-Mar-05 4:05 
Hello,



I've posted a question on code project, but didn't get a good reply.



Why does the following code isn't working:



// the input params are

szOperation =  "diff.exe"
szParams = " "C:\1.txt" "C:\WINDOWS\FileSafe\0017CF85-0029-0000-B9ED-DF4AD816684A\olvf.fs"
szCompareResFile ="C:\WINDOWS\FileSafe\0017CF85-0029-0000-B9ED-DF4AD816684A\cfv.fs.cr.1"


The called function to operate the GNU "Diff.exe" (which is based on the RGDiff application taken from code project) is :


int CFSMgr::OperateGNUDiff(CString szOperation,CString szParams,CString szCompareResFile)
{
//	_ONERR(0 < szOperation.GetLength() && 
//		   0 < szParams.GetLength()    && 
//		   0 < szDestFile.GetLength(), return -1);

	int iOperationLen = szOperation.GetLength();
	int iParamsLen    = szParams.GetLength();
	CString szCmdLine(szOperation);
	szCmdLine += _T(" ");
	szCmdLine += szParams;
	TCHAR szCmd[CMD_LINE_BUFF_LEN];
	_tcsncpy(szCmd,(LPTSTR)(LPCTSTR)szCmdLine,iOperationLen + iParamsLen + 2);

	CString szEcnrypted(szCompareResFile);
	szEcnrypted += _T(".enc");

	CString szErrFile(szCompareResFile);
	szErrFile += _T(".err");

	CCrypt c;
	DWORD dwExitCode(0);
	int iLen = szEcnrypted.GetLength();
	TCHAR szKey[] = _T("FS@CORE@");
	TCHAR* lpszEncrypted = NULL;

	BOOL bSucc(FALSE);

	try
	{
		SECURITY_ATTRIBUTES sa;
		sa.nLength = sizeof(sa);
		sa.lpSecurityDescriptor = 0;
		sa.bInheritHandle = 1;

		HANDLE hOutput = CreateFile(szCompareResFile,
									GENERIC_READ|GENERIC_WRITE,
									FILE_SHARE_WRITE | FILE_SHARE_READ,
									&sa, 
									CREATE_ALWAYS,
									FILE_ATTRIBUTE_NORMAL, 
									0);
		HANDLE hErr	= CreateFile(szErrFile,
								 GENERIC_READ|GENERIC_WRITE,
								 FILE_SHARE_WRITE | FILE_SHARE_READ,
								 &sa, 
								 CREATE_ALWAYS,
								 FILE_ATTRIBUTE_NORMAL, 
								 0);

		STARTUPINFO         siStartupInfo;
		PROCESS_INFORMATION piProcessInfo;

		::ZeroMemory(&siStartupInfo, sizeof(siStartupInfo));
		::ZeroMemory(&piProcessInfo, sizeof(piProcessInfo));

		siStartupInfo.cb			= sizeof(siStartupInfo);
		siStartupInfo.dwFlags		= STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;		
		siStartupInfo.wShowWindow	= SW_HIDE;
		siStartupInfo.hStdOutput	= hOutput;
		siStartupInfo.hStdError		= hErr;
		
		bSucc = CreateProcess(0,    
							  szCmd,	
							  0,
							  0,
							  FALSE,
							  0,
							  0,
							  0,
							  &siStartupInfo,
							  &piProcessInfo);

//	    _ONERR(bSucc, return -1);
    	
    	while (TRUE)
        {
			bSucc = GetExitCodeProcess(piProcessInfo.hProcess, &dwExitCode);
//			_ONERR(bSucc, return -1);

			if (dwExitCode != STILL_ACTIVE)
				break;
			else
				Sleep(50);
		}

		CloseHandle(piProcessInfo.hProcess);
		CloseHandle(hOutput);
		CloseHandle(hErr);

		switch (dwExitCode)
		{
			case 0:
				
				bSucc = DeleteFile(szCompareResFile);
//				_ONERR(bSucc, return -1);
				return 0;
				
			case 1:

				lpszEncrypted = new TCHAR[iLen];
				_tcscpy(lpszEncrypted,szEcnrypted);

				c.EncryptFile((LPTSTR)(LPCTSTR)szCompareResFile,lpszEncrypted,szKey);
				if (lpszEncrypted)
					SAFE_DELETE(lpszEncrypted);

				bSucc = MoveFile(szEcnrypted,szCompareResFile);
				_ONERR(bSucc, return -1);
				
				return 1;

			case 2:

				ATLASSERT(FALSE);
				return 2;
			
			default:
				ATLASSERT(FALSE);
				return -1;
		}

		return 0;
	}
	catch(...)
	{
		ATLASSERT(FALSE);
		return -1;
    }
}


CreateProcess returns TRUE (succeeded!) but the GetExitCodeProcess method puts 2 for dwExitCode which indicates a diff.exe failure!

I can't figure out what's wrong????

Can any1 help ?
Thanks in advanced
Yaron


Ask not what your application can do for you,
Ask what you can do for your application
GeneralRe: GNU diff.exe this code ins't working :( Pin
Gary R. Wheeler13-Mar-05 4:22
Gary R. Wheeler13-Mar-05 4:22 
GeneralRe: GNU diff.exe this code ins't working :( Pin
YaronNir13-Mar-05 4:29
YaronNir13-Mar-05 4:29 
GeneralRe: GNU diff.exe this code ins't working :( Pin
Gary R. Wheeler13-Mar-05 5:11
Gary R. Wheeler13-Mar-05 5:11 
GeneralRe: GNU diff.exe this code ins't working :( Pin
YaronNir13-Mar-05 5:15
YaronNir13-Mar-05 5:15 
GeneralRe: GNU diff.exe this code ins't working :( Pin
David Crow14-Mar-05 3:36
David Crow14-Mar-05 3:36 
GeneralRe: GNU diff.exe this code ins't working :( Pin
YaronNir14-Mar-05 6:39
YaronNir14-Mar-05 6:39 
Generalurgent- how to flush output buffers in VC++ Pin
Member 176156313-Mar-05 3:29
Member 176156313-Mar-05 3:29 
GeneralRe: urgent- how to flush output buffers in VC++ Pin
Gary R. Wheeler13-Mar-05 4:25
Gary R. Wheeler13-Mar-05 4:25 
GeneralRe: urgent- how to flush output buffers in VC++ Pin
Member 176156313-Mar-05 16:06
Member 176156313-Mar-05 16:06 
GeneralRe: urgent- how to flush output buffers in VC++ Pin
Member 176156314-Mar-05 0:18
Member 176156314-Mar-05 0:18 
GeneralMessenger Addon Pin
Kannan Ramanathan13-Mar-05 3:14
Kannan Ramanathan13-Mar-05 3:14 
GeneralVirtual Inheritancae and Mutiple Inheritance Pin
phijophlip13-Mar-05 3:05
phijophlip13-Mar-05 3:05 
GeneralRe: Virtual Inheritancae and Mutiple Inheritance Pin
YaronNir13-Mar-05 4:11
YaronNir13-Mar-05 4:11 
GeneralRe: Virtual Inheritancae and Mutiple Inheritance Pin
Michael Dunn13-Mar-05 4:58
sitebuilderMichael Dunn13-Mar-05 4:58 
GeneralRe: Virtual Inheritancae and Mutiple Inheritance Pin
Gary R. Wheeler13-Mar-05 5:13
Gary R. Wheeler13-Mar-05 5:13 
GeneralRe: Virtual Inheritancae and Mutiple Inheritance Pin
Gary R. Wheeler13-Mar-05 5:01
Gary R. Wheeler13-Mar-05 5:01 
GeneralEscape key Pin
gdocherty13-Mar-05 1:13
gdocherty13-Mar-05 1:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.