|
FYI[^], tox.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
i'm aware of this.
that's why I didn't answer his today's post to me...
the OP doesn't take in account the answers he got, so i stopped wasting my time and energy with him
|
|
|
|
|
Sorry sir
ok as you wish.But i always waiting for responce..
Thx's in advance
|
|
|
|
|
Thanks Sir,
My net got slow thats y I could not read your latest reply.
Now I am doing it well after closing the handle.
Thank you very much.
|
|
|
|
|
Hi toxcct
I have a error in my code.And Mr. Rajesh R Subramanian tell me that i talk to you about that problem.My problem is that .exe file is not copy and .txt file is copy.I am useing get last error then i have found Error no. 32.
The process cannot access the file because it is being used by another process.
I am useing this code
CString cs = _T("C:\\Backup\\");
cs += PathSkipRoot(strFileName);
if ( !CopyFile(strFileName, cs, TRUE))
{
DWORD dwError = GetLastError();
CString szMsg;
szMsg.Format(_T("Error number %d"), dwError);
AfxMessageBox(szMsg);
}
else
{
AfxMessageBox(_T("Success"));
}
Sir plz help me
|
|
|
|
|
You can also use of CreateProcess.
|
|
|
|
|
Hi,
I am workin on an MFC Application which is creating registry key using RegKey.Open Function.
The registry is being created in WindowsXp but does not exist for Vista
What is the problem
Thanx in Advance
Dhiraj
|
|
|
|
|
Dhiraj kumar Saini wrote: What is the problem
Vista.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
But Vista allows registries for other application such as Skype Messenger and google etc. What is the problem with my application. What is lacking in my application.
|
|
|
|
|
Dhiraj kumar Saini wrote: But Vista allows registries for other application such as Skype Messenger and google etc. What is the problem with my application. What is lacking in my application.
Your statement is baseless. No program will be allowed to create or modify registry entries if it was not run with administrative privileges.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
This has something to do with the Administrator privileges for the account that you run your application with
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Can u tell me how privileges can be changed so that the registry is created.
|
|
|
|
|
|
Thanx It seem useful.
I will try it.
|
|
|
|
|
I have created a Ribbon MDI Application and it is working fine. My problem is I am unable to reposition the frame window after restoring the frame window.What is the problem?
Ashok.R
|
|
|
|
|
Sample code is as follows:
class TestClass
{
CCriticalSection m_csTest;
void Fun1()
{
m_csTest.Lock();
Fun2();
MessageBox("In Fun1 critical section.");
m_csTest.Unlock();
}
void Fun2()
{
m_csTest.Lock();
MessageBox("In Fun2 critical section.");
m_csTest.Unlock();
}
};
I am pretty aware we should not do this. But what will be the situation? Do I need to unlock the critical section twice as shown in the code or only one time unlock is sufficient?
|
|
|
|
|
Nothing happens if you lock the critical section from the same thread twice.It prevents the thread from dead lock.
But in above case calling
m_csTest.Unlock();
twice might create problem. i am not sure about this.
May be some one else will comment on it.
Regards,
Sandip.
|
|
|
|
|
Thanks for quick response. I will wait for more replies.
|
|
|
|
|
Member 3066459 wrote: I am pretty aware we should not do this. But what will be the situation? Do I need to unlock the critical section twice as shown in the code or only one time unlock is sufficient?Confused
From MSDN:
After a thread has ownership of a critical section, it can make additional calls to EnterCriticalSection or TryEnterCriticalSection without blocking its execution. This prevents a thread from deadlocking itself while waiting for a critical section that it already owns.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
According to the docs:
http://msdn.microsoft.com/en-us/library/ms682608.aspx[^]
"A thread must call LeaveCriticalSection once for each time that it entered the critical section."
Which seems pretty clear. Even without reading them, it would be good to do a Leave for every Enter. At worst you are wasting your time. At best, it is needed.
Iain.
|
|
|
|
|
I guess only one unlock() is sufficient since it is the same critical section being requested again.
|
|
|
|
|
When call lock() its lock count will be 1. When we call again lock count will increment by 1.Hence it is necessary to call unlock() as many times you have called lock().
|
|
|
|
|
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;
}
try
{
CInternetSession Session(_T("UpdateService"));
CHttpConnection Connection1(Session,Link.c_str());
BYTE Buffer[4096];
CHttpFile dFile(Session,Link.c_str());
CInternetFile::CInfo Info(dFile);
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());
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;
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
|
|
|
|
|
You should not update UI from the worker thread.
You can send message to Main UI thread to update the progress bar.
I hope it makes sense.
Regards,
Sandip.
|
|
|
|
|
SandipG wrote: I hope it makes sense.
Actually it makes perfect sense.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|