Click here to Skip to main content
15,896,201 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWhat happens when we lock same critical section twice? Pin
SandeepNK9-Sep-08 0:24
SandeepNK9-Sep-08 0:24 
AnswerRe: What happens when we lock same critical section twice? Pin
SandipG 9-Sep-08 0:28
SandipG 9-Sep-08 0:28 
GeneralRe: What happens when we lock same critical section twice? Pin
SandeepNK9-Sep-08 0:33
SandeepNK9-Sep-08 0:33 
AnswerRe: What happens when we lock same critical section twice? Pin
Nibu babu thomas9-Sep-08 2:05
Nibu babu thomas9-Sep-08 2:05 
AnswerRe: What happens when we lock same critical section twice? Pin
Iain Clarke, Warrior Programmer9-Sep-08 4:15
Iain Clarke, Warrior Programmer9-Sep-08 4:15 
AnswerRe: What happens when we lock same critical section twice? Pin
SRKSHOME9-Sep-08 20:31
SRKSHOME9-Sep-08 20:31 
GeneralRe: What happens when we lock same critical section twice? Pin
SRKSHOME9-Sep-08 20:50
SRKSHOME9-Sep-08 20:50 
QuestionCProgressBarCtrl question Pin
monsieur_jj8-Sep-08 23:57
monsieur_jj8-Sep-08 23:57 
Hi all,

I just want to know why my progress bar wont move at all.

void CUpdateDlg::DownloadThread(string SavePath, string Link, string Name, string NameVersion)
{
	int dloadPos, finalPos;
	FILE * pFile = NULL;
	
	DWORD dwPacketSize =5;

	PBYTE  pBuffer  = new BYTE[dwPacketSize * 1024];

	double dOffsetToSeek =0;
	
	std::string strTmpFileName = SavePath.c_str();
	strTmpFileName.append(".tmp");

	std::string strFileNameAtLocalMachine= SavePath.c_str();

	int res = DeleteFile(strFileNameAtLocalMachine.c_str());
	
	double dCurrentFileSize;

	if(IfLocalFileExist(strTmpFileName.c_str(), &dCurrentFileSize)) 
	{
		dOffsetToSeek = dCurrentFileSize;
	}
	
	ATL::CString strRangeQuest;
	dloadPos = dCurrentFileSize;
	ProgressBar.SetPos(dloadPos);
	if(dCurrentFileSize>0){   
		strRangeQuest.Format( _T("%sRange: bytes=%d-\r\n"), szHeaders,static_cast<ULONGLONG>(dCurrentFileSize));
	}
	else        
		strRangeQuest = szHeaders;

	if (!(pFile = fopen (strTmpFileName.c_str(), "a+b" ) ) )
	{		
		return;
	}
	//CUpdateServiceModule UpdateService;
	try
	{ 	
	CInternetSession Session(_T("UpdateService"));

	CHttpConnection Connection1(Session,Link.c_str());

	BYTE Buffer[4096];

	CHttpFile dFile(Session,Link.c_str());
	CInternetFile::CInfo Info(dFile); //test
	dFile.SendRequest(strRangeQuest);
	DWORD dwFileLength;
	dFile.GetLength(dwFileLength);
	DWORD dwRead;	
	finalPos = dwFileLength;
	ProgressBar.SetRange(dloadPos, finalPos);
	for (dwRead = 1 ; dwRead;)	
	{
		dFile.Read(Buffer,sizeof(Buffer),dwRead);
		if (dwRead>0)
			fwrite(Buffer, sizeof (char), dwRead , pFile);	
		IfLocalFileExist(strTmpFileName.c_str(), &dCurrentFileSize);
		dloadPos = dCurrentFileSize;
		ProgressBar.SetPos(dloadPos);
	}
	fclose (pFile);
	BOOL moved = MoveFile(strTmpFileName.c_str(), strFileNameAtLocalMachine.c_str());	
	
	if(moved)
	{
		DloadCompNotify.EnableWindow(TRUE);
		EmailUser(strFileNameAtLocalMachine.c_str());
	}
	DeleteFile(strTmpFileName.c_str());
	


	//set status to 1	
	HKEY hkey;
	TCHAR szKey[256];	
	int nValue = 0;


		szKey[0] = _T('\0');							

		_tcscpy(szKey, ServiceRegEntry);
		_tcscat(szKey, UPDATEMGR);
		_tcscat(szKey, ServiceParam);
		_tcscat(szKey, _T("\\"));
		_tcscat(szKey, Name.c_str());
		_tcscat(szKey, _T("\\"));
		_tcscat(szKey, NameVersion.c_str());						

		if (RMRegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey,0,KEY_QUERY_VALUE | KEY_SET_VALUE,&hkey) == ERROR_SUCCESS)			
		{	
			nValue = 1; //finished downloading
			RMRegSetValueEx(hkey,UPDATESTAT,0,REG_DWORD,(BYTE*)&nValue,sizeof(nValue));					
			RMRegCloseKey(hkey);
		}
	}
	catch(CInternetException& err)
	{
		err.GetErrorMessage();
	}
}


Please advise what you can find out.

thanks,
Jayjay
AnswerRe: CProgressBarCtrl question Pin
SandipG 9-Sep-08 0:01
SandipG 9-Sep-08 0:01 
GeneralRe: CProgressBarCtrl question Pin
CPallini9-Sep-08 0:09
mveCPallini9-Sep-08 0:09 
GeneralRe: CProgressBarCtrl question Pin
SandipG 9-Sep-08 0:19
SandipG 9-Sep-08 0:19 
AnswerRe: CProgressBarCtrl question Pin
krmed9-Sep-08 2:09
krmed9-Sep-08 2:09 
QuestionZooming Problem Pin
Bernaad8-Sep-08 23:31
Bernaad8-Sep-08 23:31 
AnswerRe: Zooming Problem Pin
Rane8-Sep-08 23:44
Rane8-Sep-08 23:44 
QuestionHow and why does the output vary for pre and post increment operators? Pin
Member 55028798-Sep-08 23:27
Member 55028798-Sep-08 23:27 
AnswerRe: How and why does the output vary for pre and post increment operators? Pin
_AnsHUMAN_ 8-Sep-08 23:34
_AnsHUMAN_ 8-Sep-08 23:34 
AnswerRe: How and why does the output vary for pre and post increment operators? Pin
toxcct8-Sep-08 23:37
toxcct8-Sep-08 23:37 
QuestionHow to expand a button after clicking it Pin
Member 46556858-Sep-08 22:27
Member 46556858-Sep-08 22:27 
AnswerRe: How to expand a button after clicking it Pin
toxcct8-Sep-08 22:33
toxcct8-Sep-08 22:33 
GeneralRe: How to expand a button after clicking it Pin
SandipG 8-Sep-08 22:58
SandipG 8-Sep-08 22:58 
GeneralRe: How to expand a button after clicking it Pin
toxcct8-Sep-08 23:01
toxcct8-Sep-08 23:01 
GeneralRe: How to expand a button after clicking it Pin
_AnsHUMAN_ 8-Sep-08 23:05
_AnsHUMAN_ 8-Sep-08 23:05 
GeneralRe: How to expand a button after clicking it Pin
Member 46556858-Sep-08 23:22
Member 46556858-Sep-08 23:22 
GeneralRe: How to expand a button after clicking it Pin
toxcct8-Sep-08 23:24
toxcct8-Sep-08 23:24 
GeneralRe: How to expand a button after clicking it Pin
Member 46556858-Sep-08 23:30
Member 46556858-Sep-08 23:30 

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.