Esempio n. 1
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_CreateNewDFUFile(PSTR pPathFile,
						                                 PHANDLE phFile, 
														 WORD Vid,
														 WORD Pid,
														 WORD Bcd)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	
	DWORD dwRet;
	CDFUFile *pDfuFile;
	
	pDfuFile=new CDFUFile(pPathFile, CFile::modeCreate | CFile::modeReadWrite, Vid, Pid, Bcd);

	dwRet=pDfuFile->GetError();

	if (dwRet==STDFUPRT_NOERROR)
	{
		*phFile=(PHANDLE)pDfuFile;
		g_DFUFiles.Add(pDfuFile);
	}
	else
		delete pDfuFile;

	return dwRet;
}
Esempio n. 2
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_DuplicateImage(HANDLE hSource, PHANDLE pDest)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	
	DWORD dwRet=STDFUFILES_NOERROR;
	BOOL bFound=FALSE;

	for (int i=0;i<=g_Images.GetUpperBound();i++)
	{
		if ((HANDLE)g_Images.GetAt(i)==hSource)
		{
			bFound=TRUE;
			break;
		}
	}

	if (!bFound)
		dwRet=STDFUPRT_BADPARAMETER;
	else
	{
		CImage *obImage=new CImage((CImage*)hSource);
		if (obImage->GetImageState())
		{
			g_Images.Add(obImage);
			*pDest=(HANDLE)obImage;
		}
		else
		{
			delete obImage;
			dwRet=STDFUFILES_BADFORMAT;
		}
	}
	return dwRet;
}
Esempio n. 3
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_ReadImageFromDFUFile(HANDLE hFile, 
															 int Rank, 
															 PHANDLE pImage)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	BOOL bFound=FALSE;
	DWORD dwRet=STDFUPRT_NOERROR;

	for (int i=0;i<=g_DFUFiles.GetUpperBound();i++)
	{
		if ((HANDLE)g_DFUFiles.GetAt(i)==hFile)
		{
			CDFUFile *pFile=(CDFUFile *)hFile;

			dwRet=pFile->ReadImage(Rank, pImage);

			if (dwRet==STDFUFILES_NOERROR) 
				g_Images.Add((CImage*)*pImage);
	
			bFound=TRUE;
			break;
		}
	}
	if (!bFound)
		dwRet=STDFUPRT_BADPARAMETER;
	return dwRet;
}
Esempio n. 4
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_OpenExistingDFUFile(PSTR pPathFile, 
															  PHANDLE phFile, 
															  PWORD pVid, 
															  PWORD pPid, 
															  PWORD pBcd,
															  PBYTE pNbImages)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	DWORD dwRet;
	CDFUFile *pDfuFile;
	
	pDfuFile=new CDFUFile(pPathFile, CFile::modeRead);

	dwRet=pDfuFile->GetError();

	if (dwRet==STDFUPRT_NOERROR)
	{
		if (pVid)
			*pVid=pDfuFile->GetVid();
		if (pPid)
			*pPid=pDfuFile->GetPid();
		if (pBcd)
			*pBcd=pDfuFile->GetBcd();
		if (pNbImages)
			*pNbImages=pDfuFile->GetNbAlternates();
		*phFile=(PHANDLE)pDfuFile;
		g_DFUFiles.Add(pDfuFile);
	}
	else
		delete pDfuFile;

	return dwRet;
}
Esempio n. 5
0
//------------------------------------------------------------------------
void CMRCFrameWndSizeDock::DestroyDynamicBars()
// Destroys the dynamic bars in an application
//------------------------------------------------------------------------
{
	CPtrList & listControlBars = m_listControlBars;
	
	CObArray arrBars;
	CMRCSizeControlBar* pBar;
	
	// pass through the list and build an array of bars to destroy
	POSITION pos = listControlBars.GetHeadPosition();
	while (pos != NULL)
	{
		pBar = (CMRCSizeControlBar *) listControlBars.GetNext(pos);
		ASSERT(pBar != NULL);
		if (pBar->IsKindOf(RUNTIME_CLASS(CMRCSizeControlBar)) &&
				(pBar->m_Style & SZBARF_AUTOTIDY) != 0)
			arrBars.Add(pBar);
	}

	// now destroy these bars...
	for (int i = arrBars.GetUpperBound(); i >= 0; i--)
	{
		pBar = (CMRCSizeControlBar *) arrBars[i];
		pBar->DestroyWindow();
	}
}
Esempio n. 6
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_CreateImageFromMapping(PHANDLE pHandle, PMAPPING pMapping)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	DWORD Ret=STDFUFILES_BADPARAMETER;

	CImage *pImage=new CImage(pMapping, FALSE, NULL);
	if (pImage)
	{
		g_Images.Add(pImage);
		*pHandle=(HANDLE)pImage;
		Ret=STDFUFILES_NOERROR;
	}
	return Ret;
}
// 合并之后重新计算loop的邻接优先级
void CP_LoopExt::CalcLoopAdjFaceNum()
{
	CObArray tmpAdjLoopArr;

	int halfSize = GetHalfNumber();
	for(int i = 0; i < halfSize; i++)
	{
		CP_LoopExt * adjLoop = (CP_LoopExt *)GetHalf(i)->m_pTwin->m_pLoop;
		if(adjLoop->m_adjFaceNum != -1) continue;
		int j;
		for (j = 0; j < tmpAdjLoopArr.GetSize(); ++j) {
			if (tmpAdjLoopArr[j] == adjLoop)
				break;
		}
		if (j == tmpAdjLoopArr.GetSize()) tmpAdjLoopArr.Add(adjLoop);
	}
	m_adjFaceNum = tmpAdjLoopArr.GetSize();
	tmpAdjLoopArr.RemoveAll();
}
Esempio n. 8
0
//-----------------------------------------------------------------
void CMRCFrameWndSizeDock::GetFloatingBars(CObArray & arrWnd)
// Appends the floating bars, visible bars to an array
//-----------------------------------------------------------------
{
	CPtrList & listControlBars = m_listControlBars;
	
	POSITION pos = listControlBars.GetHeadPosition();
	while (pos != NULL)
	{
		CControlBar* pBar = (CControlBar*)listControlBars.GetNext(pos);
		ASSERT(pBar != NULL);
		if (!pBar->IsDockBar() && pBar->IsFloating() && pBar->IsVisible()) 	// not a dockbar and floating....
		{
			ASSERT(pBar->m_pDockBar != NULL);
			CWnd * pFloatFrame = ((CWnd *)pBar->m_pDockBar)->GetParent(); 
			ASSERT(pBar != NULL);
			arrWnd.Add(pFloatFrame);
		}
	}
}
Esempio n. 9
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_ImageFromFile(PSTR pPathFile, PHANDLE pImage, BYTE nAlternate)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	
	DWORD Ret=STDFUFILES_BADPARAMETER;

	CImage *obImage=new CImage(nAlternate, pPathFile, FALSE, NULL);
	if (obImage)
	{
		if (obImage->GetImageState())
		{
			g_Images.Add(obImage);
			*pImage=(HANDLE)obImage;
			Ret=STDFUFILES_NOERROR;
		}
		else
		{
			delete obImage;
			Ret=STDFUFILES_BADFORMAT;
		}
	}
	return Ret;
}
LPMAPIFOLDER CExMapi::GetContacts(LPMAPIFOLDER pFolder,LONG& folderCount,LONG& contactCount,LONG& skipCount,LONG& contactIndex,CObArray& contactArray,BOOL doLog)
{
	__recursionCount++;
	wchar_t buffer[5];
	_itow(__recursionCount,buffer,10);
	if(doLog)
	{
		if(__recursionCount > 1)
			m_logHelper.LogPAB(L"-------------------------------------");
		m_logHelper.LogPAB(L"Recursive Call No: "+CString(buffer));
		m_logHelper.LogPAB(L"-------------------------------------");
	}
	CString strFilterBy = m_pCtrl->GetPABSerachBy();
	CString strStartWith = m_pCtrl->GetPABSerachStartWith();
	strStartWith = strStartWith.MakeLower();
	ULONG pageSize;
	m_pCtrl->get_PABPageSize(&pageSize);
	LONG pageNumber = m_pCtrl->GetPABPageNumber();
	LONG startIndex = -1;
	if(pageSize>0)
	{
		startIndex = (pageSize * pageNumber) - pageSize;
	}

	LPMAPIFOLDER pSubFolder=NULL;
	LPMAPITABLE pHierarchy;
	CString strFolder;

	try
	{
		if(doLog)
			m_logHelper.LogPAB(L"RELEASE(m_pHierarchy); START");

		RELEASE(m_pHierarchy);
		
		if(doLog)
			m_logHelper.LogPAB(L"RELEASE(m_pHierarchy); END");

		if(doLog)
			m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder); START");

		pHierarchy = GetHierarchy(pFolder);

		if(doLog)
			m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder); END");

		if(pHierarchy) 
		{
			LPMAPIFOLDER pRecurse = NULL;
			do 
			{
				RELEASE(pSubFolder);
				m_pHierarchy = pHierarchy;			

				if(doLog)
					m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder); START");

				pSubFolder = GetNextSubFolder(strFolder,pFolder);

				if(doLog)
					m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder); END");
			
				if(pSubFolder) 
				{
					//if(strFolder == L"Deleted Items")
					//	continue;

					if(IsContactFolder(pSubFolder))
					{
						folderCount++;
	 					if(doLog)
							m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) START");

						if(GetContents(pSubFolder))
						{
							if(doLog)
								m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) END");

							SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME);
							//SortContents(TABLE_SORT_ASCEND,PR_SUBJECT);

							CString strText;
							CExMapiContact mapiContact;
							CString name;
							CString email;
							BOOL mustFilter = FALSE;
							mustFilter = strStartWith != "";
							
							if(doLog)
								m_logHelper.LogPAB(L"Start Reading Contact properties");

							while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) 
							{
								if(pageSize > 0)
								{
									if(contactCount == pageSize)
									{
										break;								
									}
								}

								contactIndex++;
								if(mustFilter)
								{
									if(strFilterBy == "Name")
									{
										mapiContact.GetName(name,PR_GIVEN_NAME);
										name = name.MakeLower();
										if(name.Find(strStartWith) != 0)				
										{
											continue;									
										}
									}

									if(strFilterBy == "Email")
									{
										mapiContact.GetEmail(email);
										email = email.MakeLower();
										if(email.Find(strStartWith) != 0)
										{
											continue;
										}
									}																
								}
								if(startIndex > 0 && skipCount < startIndex)
								{
									skipCount++;
									continue;								
								}

								CContact* pContact = new CContact();

								pContact->SetId(contactIndex);

								pContact->SetFolderName(strFolder);

								mapiContact.GetName(strText);
								pContact->SetFullName(strText);

								mapiContact.GetCompany(strText);
								pContact->SetCompany(strText);

								mapiContact.GetIMAddress(strText);
								pContact->SetIMAddress(strText);

								mapiContact.GetName(strText,PR_GIVEN_NAME);
								pContact->SetFirstName(strText);

								mapiContact.GetName(strText,PR_MIDDLE_NAME);
								pContact->SetMiddleName(strText);

								mapiContact.GetName(strText,PR_SURNAME);
								pContact->SetLastName(strText);

								mapiContact.GetEmail(strText);
								pContact->SetEmail(strText);	

								mapiContact.GetEmail(strText,2);//Email 2
								pContact->SetEmail2(strText);

								mapiContact.GetEmail(strText,3);//Email 3
								pContact->SetEmail3(strText);

								mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER);
								pContact->SetBusinessPhone(strText);

								mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER);
								pContact->SetCompanyPhone(strText);

								mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER);
								pContact->SetFax(strText);

								mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER);
								pContact->SetMobilePhone(strText);

								mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER);
								pContact->SetHomePhone(strText);

								if(m_pCtrl->FetchUnique())
								{
									BOOL isContactExist = FALSE;
									for(int i=0;i<contactArray.GetCount();i++)
									{
										CContact* pTemp = (CContact*)contactArray.GetAt(i);

										if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail())
										{
											isContactExist = TRUE;
											break;																	
										}
										else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName())
										{
											isContactExist = TRUE;
											break;
										}
										else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone())
										{
											isContactExist = TRUE;
											break;
										}
										else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone())
										{
											isContactExist = TRUE;
											break;
										}
										else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone())
										{
											isContactExist = TRUE;
											break;
										}
									}

									if(isContactExist)
									{
										continue;
									}
								}														
								contactArray.Add(pContact);							
								contactCount++;							
							}
						}
					}

					m_pHierarchy = NULL; // so we don't release it in subsequent drilldown
					if(pageSize > 0)
					{
						if(contactCount == pageSize)
							break;								
					}
					
					if(__recursionCount < m_pCtrl->GetSubFOlderLevel())
					{
						pRecurse = GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog);
					}
					if(pRecurse) 
					{
						RELEASE(pSubFolder);
						pSubFolder = pRecurse;
						break;
					}
				}
				else
				{
					__recursionCount = 1;
				}
				if(pageSize > 0)
				{
					if(contactCount == pageSize)
						break;								
				}

			} while(pSubFolder && !m_pCtrl->IsPABSearchAbort());
			RELEASE(pHierarchy);
			m_pHierarchy=NULL;
		}
		// this may occur many times depending on how deep the recursion is; make sure we haven't already assigned m_pFolder
		if(pSubFolder && m_pFolder!=pSubFolder) {
			RELEASE(m_pFolder);
			m_pFolder=pSubFolder;
		}
	}
	catch(_com_error &e)
	{
		if(doLog)
		{
			m_logHelper.LogPAB(L"GetContactFolderCount Exception Catch START:");
			m_logHelper.LogPAB(L"FolderName: " + strFolder );
			m_logHelper.LogPAB(e.ErrorMessage());
			m_logHelper.LogPAB(L"GetContactFolderCount Exception Catch END:");
		}
	}
	return pSubFolder;
} 
BOOL CExMapi::GetContacts(CObArray& contactArray,CTRError& error)
{
	BOOL doLog = m_pCtrl->IsEnableLog();
	if(doLog)
	{
		m_logHelper.LogPAB(L"------------------------------------");
		m_logHelper.LogPAB(L"Function GetPABCotacts START:");
		m_logHelper.LogPAB(L"------------------------------------");
	}

	CString strFilterBy = m_pCtrl->GetPABSerachBy();
	CString strStartWith = m_pCtrl->GetPABSerachStartWith();
	strStartWith = strStartWith.MakeLower();
	ULONG pageSize;
	m_pCtrl->get_PABPageSize(&pageSize);
	ULONG pageNumber = m_pCtrl->GetPABPageNumber();
	LONG contactCount = 0;
	LONG skipCount = 0;
	LONG startIndex = -1;
	LONG contactIndex = 0;
	LONG folderCount = 0;
	if(pageSize>0)
	{
		startIndex = (pageSize * pageNumber) - pageSize;
	}

	CString strFolder;
	int msgStoreCount = 0;
	wchar_t buffer[5];

	LPMAPIFOLDER pSubFolder=NULL;	
	LPMAPITABLE lpMsgStoreTable = NULL;
	lpMsgStoreTable = GetMessageStoresTable();	
	if(lpMsgStoreTable)
	{
		while(OpenNextMessageStore(lpMsgStoreTable))
		{	
			//GetContacts(OpenRootFolder(),folderCount,contactCount,skipCount,contactIndex,contactArray);

			msgStoreCount++;
			_itow(msgStoreCount,buffer,10);
			if(doLog)
			{
				if(msgStoreCount > 1)
					m_logHelper.LogPAB(L"-------------------------------------");
				m_logHelper.LogPAB(L"Message Store No : "+CString(buffer));
				m_logHelper.LogPAB(L"-------------------------------------");
			}

			pSubFolder = OpenContacts();
			if(pSubFolder && IsContactFolder(pSubFolder))
			{
				if(doLog)
					m_logHelper.LogPAB(L"Open Main Contacts Folder");

				strFolder = GetFolderName(pSubFolder);
				folderCount++;
				if(GetContents(pSubFolder))
				{
					SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME);
					//SortContents(TABLE_SORT_ASCEND,PR_SUBJECT);

					CString strText;
					CExMapiContact mapiContact;
					CString name;
					CString email;
					BOOL mustFilter = FALSE;
					mustFilter = strStartWith != "";
					
					if(doLog)
						m_logHelper.LogPAB(L"Start reading contacts from main contact fodler");

					while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) 
					{
						if(pageSize > 0)
						{
							if(contactCount == pageSize)
							{
								break;								
							}
						}

						contactIndex++;
						if(mustFilter)
						{
							if(strFilterBy == "Name")
							{
								mapiContact.GetName(name,PR_GIVEN_NAME);
								name = name.MakeLower();
								if(name.Find(strStartWith) != 0)				
								{
									continue;									
								}
							}

							if(strFilterBy == "Email")
							{
								mapiContact.GetEmail(email);
								email = email.MakeLower();
								if(email.Find(strStartWith) != 0)
								{
									continue;
								}
							}																
						}
						if(startIndex > 0 && skipCount < startIndex)
						{
							skipCount++;
							continue;								
						}

						CContact* pContact = new CContact();

						pContact->SetId(contactIndex);

						pContact->SetFolderName(strFolder);

						mapiContact.GetName(strText);
						pContact->SetFullName(strText);

						mapiContact.GetCompany(strText);
						pContact->SetCompany(strText);

						mapiContact.GetIMAddress(strText);
						pContact->SetIMAddress(strText);

						mapiContact.GetName(strText,PR_GIVEN_NAME);
						pContact->SetFirstName(strText);

						mapiContact.GetName(strText,PR_MIDDLE_NAME);
						pContact->SetMiddleName(strText);

						mapiContact.GetName(strText,PR_SURNAME);
						pContact->SetLastName(strText);

						mapiContact.GetEmail(strText);
						pContact->SetEmail(strText);	

						mapiContact.GetEmail(strText,2);//Email 2
						pContact->SetEmail2(strText);

						mapiContact.GetEmail(strText,3);//Email 3
						pContact->SetEmail3(strText);

						mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER);
						pContact->SetBusinessPhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER);
						pContact->SetCompanyPhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER);
						pContact->SetFax(strText);

						mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER);
						pContact->SetMobilePhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER);
						pContact->SetHomePhone(strText);

						if(m_pCtrl->FetchUnique())
						{
							BOOL isContactExist = FALSE;
							for(int i=0;i<contactArray.GetCount();i++)
							{
								CContact* pTemp = (CContact*)contactArray.GetAt(i);

								if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail())
								{
									isContactExist = TRUE;
									break;																	
								}
								else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone())
								{
									isContactExist = TRUE;
									break;
								}
							}

							if(isContactExist)
							{
								continue;
							}
						}														
						contactArray.Add(pContact);							
						contactCount++;							
					}
				}
				if(doLog)
					m_logHelper.LogPAB(L"Open Sub Contacts Folder");
				GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog);
			}
			if(pageSize > 0)
			{
				if(contactCount == pageSize)
					break;								
			}
			if(m_pCtrl->IsPABSearchAbort())
				break;
			__recursionCount = 0;
		}
	}	
	if(doLog)
	{
		m_logHelper.LogPAB(L"------------------------------------");
		m_logHelper.LogPAB(L"Function GetPABCotacts END:");
		m_logHelper.LogPAB(L"------------------------------------");	
		m_logHelper.ClosePABLog();
	}
	__recursionCount = 0;
	RELEASE(lpMsgStoreTable);		

	if(folderCount == 0 && !m_pCtrl->IsPABSearchAbort())
	{
		error.code = 107;
		error.err = "TRContactFinder Cannot find private folders.";
		return FALSE;
	}

	return TRUE;
}
int CExecCommand::execWaitForAllChilds( LPCTSTR lpstrCommand, LPCTSTR lpstrPath)
{
	CObArray		myProcessList;
	CProcessProps	*pProcess;
	DWORD			dwExitCode,
					dwProcessID,
					dwTime = 0;

	try
	{
		ASSERT( lpstrCommand);

		// Start process
		initialize();
		if ((dwProcessID = realCreateProcess( lpstrCommand, lpstrPath)) == 0) 
		{
			closeHandles();
			return EXEC_ERROR_START_COMMAND;
		}
		// We need high priority on OS to follow thread/process created by main command
		SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS);
		// Store first process
		pProcess = new CProcessProps();
		pProcess->set( dwProcessID, GetCurrentProcessId(), lpstrCommand);
		myProcessList.Add( pProcess);
		// While there is running processes or timeout not reached
		while ((myProcessList.GetCount() > 0) && (dwTime < m_dwTimeout))
		{
			// Parse memory processes for new childs process or terminated processes
			if (!parseRunningProcesses( &myProcessList))
			{
				SetPriorityClass( GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
				m_csOutput.Format( "Parse running processes Error: %s", GetAnsiFromUnicode( LookupError( GetLastError())));
				freeProcessList( &myProcessList);
				closeHandles();
				return EXEC_ERROR_WAIT_COMMAND;
			}
			Sleep( EXEC_WAIT_CHECK_LATENCY);
			dwTime += EXEC_WAIT_CHECK_LATENCY;
		}
		freeProcessList( &myProcessList);
		// Now return to normal prioity
		SetPriorityClass( GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
		// Get exit code
		if (GetExitCodeProcess( m_hProcessHandle, &dwExitCode)) 
		{
			m_nExitValue = dwExitCode;
		}
		else
		{
			m_nExitValue = -1;
			m_csOutput.Format( "GetExitCode Error: %s", GetAnsiFromUnicode( LookupError( GetLastError())));
			closeHandles();
			return EXEC_ERROR_WAIT_COMMAND;
		}
		closeHandles();
		return EXEC_SUCCESSFULL;
	}
	catch (CException *pEx)
	{
		pEx->Delete();
		closeHandles();
		m_csOutput = "Unhandled exception Error";
		return EXEC_ERROR_START_COMMAND;
	}
}