John Karlsson
2005-08-03 10:29:02 UTC
Hi all.
I'm using the SHFileOperation function in the following manner, but keep
getting the error UI whenever a file path is incorrect, even when
FOF_NOERRORUI in SHFILEOPSTRUCT.fFlags is set. ".hwnd" should hold the handle
to the window where the notification is to be displayed normally, but my
application is non-graphical, and can't wait for user intervention. Therefore
I set SHFILEOPSTRUCT.hwnd = NULL, but if an error occur I get a popup anyway.
The only way it seams I can get rid of the popup is setting .hwnd to a
random dummy value, but it doesn't feel very safe. Is it? What should I do
otherwise?
int ShFileCopy( LPCWSTR lpszTo, LPCWSTR lpszFrom, LPCWSTR lpszText, BOOL
bUseGUI, HWND hwndHandle)
{
SHFILEOPSTRUCT shfoInfo;
shfoInfo.hwnd = (bUseGUI ? hwndHandle : (HWND__ *)5335);
shfoInfo.wFunc = FO_COPY;
shfoInfo.fFlags = (bUseGUI ? 0 : FOF_SILENT | FOF_NOERRORUI |
FOF_NOCONFIRMMKDIR | FOF_NOCONFIRMATION);
// shfoInfo.fFlags = FOF_NOERRORUI;
shfoInfo.lpszProgressTitle = &_T("Copying files");
shfoInfo.pFrom = lpszFrom;
shfoInfo.pTo = lpszTo;
int nRet = SHFileOperation(&shfoInfo);
if( nRet != 0 ){
// File operation error
// Notify
RETAILMSG(TRUE, (_T("ERROR: SHFileOperation returned:
%d\r\n"), nRet));
}
return nRet;
}
Is the FOF_NOERRORUI flag ignored when .hwnd = NULL? Does .hwnd remain
unused if FOF_NOERRORUI is set (.hwnd != NULL). In that case my code should
be safe, but I don't have the code for the implementation...
I'm using the SHFileOperation function in the following manner, but keep
getting the error UI whenever a file path is incorrect, even when
FOF_NOERRORUI in SHFILEOPSTRUCT.fFlags is set. ".hwnd" should hold the handle
to the window where the notification is to be displayed normally, but my
application is non-graphical, and can't wait for user intervention. Therefore
I set SHFILEOPSTRUCT.hwnd = NULL, but if an error occur I get a popup anyway.
The only way it seams I can get rid of the popup is setting .hwnd to a
random dummy value, but it doesn't feel very safe. Is it? What should I do
otherwise?
int ShFileCopy( LPCWSTR lpszTo, LPCWSTR lpszFrom, LPCWSTR lpszText, BOOL
bUseGUI, HWND hwndHandle)
{
SHFILEOPSTRUCT shfoInfo;
shfoInfo.hwnd = (bUseGUI ? hwndHandle : (HWND__ *)5335);
shfoInfo.wFunc = FO_COPY;
shfoInfo.fFlags = (bUseGUI ? 0 : FOF_SILENT | FOF_NOERRORUI |
FOF_NOCONFIRMMKDIR | FOF_NOCONFIRMATION);
// shfoInfo.fFlags = FOF_NOERRORUI;
shfoInfo.lpszProgressTitle = &_T("Copying files");
shfoInfo.pFrom = lpszFrom;
shfoInfo.pTo = lpszTo;
int nRet = SHFileOperation(&shfoInfo);
if( nRet != 0 ){
// File operation error
// Notify
RETAILMSG(TRUE, (_T("ERROR: SHFileOperation returned:
%d\r\n"), nRet));
}
return nRet;
}
Is the FOF_NOERRORUI flag ignored when .hwnd = NULL? Does .hwnd remain
unused if FOF_NOERRORUI is set (.hwnd != NULL). In that case my code should
be safe, but I don't have the code for the implementation...
--
Regards,
John Karlsson
Teleca Sweden West AB
john dot karlsson at sys dot teleca dot se
Regards,
John Karlsson
Teleca Sweden West AB
john dot karlsson at sys dot teleca dot se