<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 32: &amp;quot;Invalid Handle&amp;quot; error when copying files</title><link>https://sourceforge.net/p/tpshellshock/bugs/32/</link><description>Recent changes to 32: &amp;quot;Invalid Handle&amp;quot; error when copying files</description><atom:link href="https://sourceforge.net/p/tpshellshock/bugs/32/feed.rss" rel="self"/><language>en</language><lastBuildDate>Wed, 29 Jan 2003 23:43:50 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/tpshellshock/bugs/32/feed.rss" rel="self" type="application/rss+xml"/><item><title>&amp;quot;Invalid Handle&amp;quot; error when copying files</title><link>https://sourceforge.net/p/tpshellshock/bugs/32/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Exported from Bugzilla, issue 4098.&lt;/p&gt;
&lt;p&gt;--- Comment added on 11/18/02 11:19:13 AM ---&lt;br /&gt;
After installation of Internet Explorer 6 on evidently ANY win32 platform (or &lt;br /&gt;
if IE6 is the default for the OS, e.g. for WinXP), the SHFileOperation API &lt;br /&gt;
starts throwing an error when copying files:&lt;/p&gt;
&lt;p&gt;this is propagated out of TStFileOperation and has caused some customer &lt;br /&gt;
distress.&lt;/p&gt;
&lt;p&gt;To reproduce using the API:&lt;/p&gt;
&lt;p&gt;Customer report:&lt;br /&gt;
Actually, I was able to reproduce this using straight calls to&lt;br /&gt;
SHFileOperation under Visual C++ with the following code:&lt;/p&gt;
&lt;p&gt;int APIENTRY WinMain(HINSTANCE hInstance,&lt;br /&gt;
HINSTANCE hPrevInstance,&lt;br /&gt;
LPSTR lpCmdLine,&lt;br /&gt;
int nCmdShow)&lt;br /&gt;
{&lt;br /&gt;
SHFILEOPSTRUCT fileOp;&lt;br /&gt;
HRESULT res;&lt;/p&gt;
&lt;p&gt;fileOp.hwnd = NULL;&lt;br /&gt;
fileOp.wFunc = FO_COPY;&lt;/p&gt;
&lt;p&gt;fileOp.pFrom = &amp;amp;quot;E:\\testfile.zip\0\0&amp;amp;quot;;&lt;br /&gt;
fileOp.pTo = &amp;amp;quot;Z:\\testfile.zip\0\0&amp;amp;quot;;&lt;/p&gt;
&lt;p&gt;fileOp.fFlags = FOF_ALLOWUNDO | FOF_FILESONLY;&lt;/p&gt;
&lt;p&gt;fileOp.hNameMappings = 0;&lt;br /&gt;
fileOp.lpszProgressTitle = &amp;amp;quot;Title&amp;amp;quot;;&lt;/p&gt;
&lt;p&gt;res = SHFileOperation(&amp;amp;amp;fileOp);&lt;/p&gt;
&lt;p&gt;res = GetLastError(); // At this point &amp;amp;quot;res&amp;amp;quot; = 6 under IE6&lt;/p&gt;
&lt;p&gt;printf(&amp;amp;quot;res: %d&amp;amp;quot;, res);&lt;/p&gt;
&lt;p&gt;return 0;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;&amp;amp;quot;Stephen Posey [TurboPower Software]&amp;amp;quot; &amp;amp;lt;stephenp@turbopower.com&amp;amp;gt; wrote in&lt;br /&gt;
message news:3C471611.F29BEED5@turbopower.com...&lt;br /&gt;
&amp;amp;gt; rcf2 wrote:&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; Has anyone had any problems with SysTools implementation of shFileOperation?&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; The problem I am having is that I get an error everytime when copying a file&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; with IE6 installed. After systools calls SHFileOperation() it then calls a&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; routine called CheckSystemError(Res).&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; The CheckSystemError routine checks the result of the SHFileOperation (res).&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; Then if it is 0 it checks GetLastError.&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; procedure TStShellComponent.CheckSystemError(ErrCode : Integer);&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; var&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; Buff : array [0..1023] of Char;&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; begin&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; if ErrCode &amp;amp;lt;&amp;amp;gt; 0 then&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; FError := ErrCode&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; else&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; FError := GetLastError;&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; .......&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; The problem arises when IE6 is installed. For me, on two different machines&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; with IE6, GetLastError returns 6 (The handle is Invalid) when called after a&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; successful SHFileOperation (ie, SHFileOperation() = 0)&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; &amp;amp;gt; With the same code under IE5 there is no problem. GetLastError returns 0.&lt;br /&gt;
&amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; Yup, known problem.&lt;br /&gt;
&amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; Oddly enough, calling SHFileOperation directly doesn't seem to cause the&lt;br /&gt;
&amp;amp;gt; problem; so, presumably, it's somewhere in the TStFileOperation.Execute&lt;br /&gt;
&amp;amp;gt; method setup.&lt;br /&gt;
&amp;amp;gt;&lt;br /&gt;
&amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; We're still trying to work out exactly where the difference arises.&lt;br /&gt;
&amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; Thanks for the report.&lt;br /&gt;
&amp;amp;gt;&lt;br /&gt;
&amp;amp;gt; Stephen Posey [TurboPower Software]&lt;br /&gt;
&amp;amp;gt; --&lt;br /&gt;
&amp;amp;gt; Please respond to the newsgroups and not via email.&lt;br /&gt;
&amp;amp;gt; This way, everyone benefits from knowing what was said.&lt;br /&gt;
&amp;amp;gt; Replies to mailsupport@turbopower.com will be copied back&lt;br /&gt;
&amp;amp;gt; to the newsgroup.&lt;/p&gt;
&lt;p&gt;--------------------&amp;amp;gt;8 cut here 8&amp;amp;lt;--------------------&lt;/p&gt;
&lt;p&gt;Customer John Wargo in a phone conversation says that he's seen reports on the &lt;br /&gt;
NET that this error can be addressed by properly zeroing the file name buffers &lt;br /&gt;
prior to calling the API.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Wed, 29 Jan 2003 23:43:50 -0000</pubDate><guid>https://sourceforge.net57cc05da56e8548b844ff6bb891e517841d15614</guid></item></channel></rss>