|
Hi All
I am useing SHFileOperation for copy folder.It's working nice for folder.Can i use SHFileOperation for file also.I mean when i copy folder like this.
C:\\Test(Source Folder)
C:\\Test2(Deswtination folder)
This is working fine.
But when i copy file like this then it's not working.
C:\\log.txt(Source)
C:\\ (Destination)
Plz help me
|
|
|
|
|
MsmVc wrote: C:\\log.txt(Source)C:\\ (Destination)
And whats should it do (i.e. what is the expected 'working' behaviour)?
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]
|
|
|
|
|
void CTestgarbageDlg::OnButton1()
{
SHFILEOPSTRUCT shop;
shop.hwnd = this->GetSafeHwnd();
shop.wFunc = FO_COPY;
shop.pFrom = _T("c:\\AUTOEXEC.BAT\0");
shop.pTo = _T("d:\0");
shop.fFlags = FOF_FILESONLY;
int iRet = -1;
iRet = SHFileOperation(&shop);
if (iRet == 0)
{
AfxMessageBox(_T("sucess"));
}
else
{
AfxMessageBox(_T("fail"));
}
}
I've tried the code above, it works fine. Hope it helps you.
|
|
|
|
|
fantasy1215 wrote: shop.pFrom = _T("c:\\AUTOEXEC.BAT\0");
shop.pTo = _T("d:\0");
Why do you double terminate the strings?
Nevermind, it was my ignorance.
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]
modified on Monday, October 6, 2008 4:38 AM
|
|
|
|
|
Documentation says to end it with two null chars.
Rajesh has verified it it works with single null termination also.
Regards,
Sandip.
|
|
|
|
|
SandipG wrote: Rajesh has verified it it works with single null termination also.
Actually, I just said that it worked in *that particular* case, as it might work with certain cases, which cannot be predicted.
But that isn't the best thing to do. Because if there is a buffer overrun, then that could be disastrous. And - Those strings must be double null-terminated.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
You're definitely a nit-picker!
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]
|
|
|
|
|
Yes, I agree..
Regards,
Sandip.
|
|
|
|
|
SandipG wrote: Documentation says to end it with two null chars.
Thank you.
SandipG wrote: Rajesh has verified it it works with single null termination also.
I know he likes the pragmatic approach.
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]
|
|
|
|
|
Hi,
I am working in MFC and i am having a chat dilaog box in which there is an edit box. I want to send send what the user is doing on the edit box used for sending message. For this I am using the notificatio ON_EN_CHANGE();
I have declared it as follows in My Class COperChatDlg:
afx_msg void OnChangeEdit();
ON_EN_CHANGE(IDC_EDIT_OP, OnChangeEdit)
and defined it as
void COperChatDlg::OnChangeEdit()
{
static bool bSend = false;
CString strText;
GetDlgItemText(IDC_EDIT_OP,strText);
int nTextLen = strText.GetLength();
if(!bSend)
{
bSend = true;
SendOperatorTypingStatus();
}
else if(nTextLen != 0 && nTextLen % 5 == 0)
{
bSend = false;
}
}
But its giving the error in the while loop of below code during run time as soon as i start typing anything in the editbox IDC_EDIT_OP.
#endif /* _SAFECRT_IMPL */
++p;
++p;
}
/* textlen now contains length in multibyte chars */
} else {
if (text.wz == NULL) /* NULL passed, use special string */
text.wz = __wnullstring;
bufferiswide = 1;
pwch = text.wz;
while (i-- && *pwch)
++pwch;
textlen = (int)(pwch - text.wz); /* in wchar_ts */
/* textlen now contains length in wide chars */
}
#else /* _UNICODE */
please help me.
Thanks In Advance.
|
|
|
|
|
what is the error that u r getting?
|
|
|
|
|
Chandrasekharanp wrote: what is the error that u r getting?
plz dn uz sms lang. PLZ.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Did you try debugging to see what happens ? And please, for the hundredth time, use the "code block" tag to submit code
|
|
|
|
|
Hi I am new to the MFC applications in vc++.
In my application I want to access the contents of second dialog box from the first,I created the object for the second dialog box and tried to access the values of the controls without saying domodal() but it is giving an error.
How can i handle this problem????????
Thanks in advance....
|
|
|
|
|
And the error is.........
BTW it's a good practice to have get/set methods implemented in your class to do this.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
i dont think its possible to get the values of the second dialog if the second dialog is not created. DoModal has to be called. otherwise u need to use a modaless dialog box.
|
|
|
|
|
We have one application written in MFC (dialog based). This application performs some admin activities such as loading Driver (.SYS file). This application helps in loading such drivers if user does not have admin credentials i.e. user is a normal user with limited credentials.
But the problem now is, if I am adding some more functionalities into it (e.g. one more function added to it) and compiled it, compilation become successfull but it is crashing at run-time. Following is the code that is written into it. I am not able to understand what it does because this is code is written by someone else. Please help me to understand this and also does this code creates problem during runtime.
Thanks
SNI
jhghjghj
modified on Tuesday, October 14, 2008 12:13 AM
|
|
|
|
|
Those assembly lines just calls a function at the address 0402EE0h. Also it passes three parameters to that function.
The only problem I see is if the 0402EE0h doesnt point to starting of a valid function address. There is a possibility that the function address has changed since you have done some code modification. So find out the correct function adress and replace it in the assembly.
Since the function address is 0402EE0h now, I guess the function resides in the main exe itself. And I wonder why would some one call its own function in this manner...
modified on Monday, October 6, 2008 2:31 AM
|
|
|
|
|
Thanks for your reply. But I need to know how to compute this address. Pls let me know if there is any way of computing it.
Is the size of binary after adding any functionality creates any problem? However if I am deleting some function calls from code then there will be no crashing but program will crash as soon as I am adding a single function call. Pls suggest.
jhghjghj
|
|
|
|
|
SNI wrote: But I need to know how to compute this address
Undo all the changes in the code( I mean removing all the newly added functionality ). Debug the code and step in(F11) at the line "Call ECX". At this time if your code has debug information, debugger will display the name of the function at 0402EE0h.
After this, add the new functionalities, find the new address of the function and replace the address in assembly code. How ever if possible try to call this function in normal way. The same problem may again come in the future...
|
|
|
|
|
Thanks for this i am trying for this option. But I want to know whether the same code will work in .Net framwork after conversion. because when I am porting the same code in VC++ .Net then it is crashing. Let me know if addresses that mentioned are going to change or remains same.
Also let me know is there any tool available to find out the new address of function (once we identify the function) after changing binaries. We have multithreaded application and it is difficult to find out function name and their addresses in debug version. We can run debug version get the address but how can we able to find out the same for release version.
jhghjghj
|
|
|
|
|
I am not a .net expert, how ever i think calling a function with hard coded function address will make situation more comlpex. In my understanding , the .net codes are generated at run time. so I guess all the function address will be having dynamic address. Some time, each time you run the exe, the function address may change( I am not sure ). So it will be little diffcult to get it worked in .net environment.
You better get ask some .net experts about the run time compilation in .net. Also isn't it possible to call the function in normal method..?
|
|
|
|
|
No it is not possible to call funcion directly because we need to perform some operations before calling that function.
jhghjghj
|
|
|
|
|
|
The problem is the above assemply code is written in a thread and this thread is gets called on some event has occured.
jhghjghj
|
|
|
|