TSHFileOpStruct的应用(50分)

  • 主题发起人 zhanghua
  • 开始时间
Z

zhanghua

Unregistered / Unconfirmed
GUEST, unregistred user!
用如下程序完成拷贝功能时,报告文件错<br>procedure TForm1.Button1Click(Sender: TObject); <br>var <br>&nbsp;F : TShFileOpStruct; <br>begin <br>&nbsp;F.Wnd := Handleaway <br>&nbsp;F.wFunc := FO_COPY; <br>&nbsp;F.pFrom := 'D:/a.db'; <br>&nbsp;F.pTo := 'C:/b.db'; <br>&nbsp;F.fFlags := FOF_ALLOWUNDO or FOF_RENAMEONCOLLISION; <br>&nbsp;if ShFileOperation(F) &lt;&gt; 0 then ShowMessage('Failed'); <br>end;<br>但是拷贝*。TXT文件时可以。 <br>
 
&nbsp; 可能是 A.DB 或 B.DB正在被别的程序或你的程序使用, <br>所以你的程序无法打开他们而出错. <br><br>&nbsp; &nbsp;你可以用GETLASTERROR()取得错误号, 来查出到底是<br>会么错误. 或者ShFileOperation(F)的返回值可以指出是<br>什么错误.
 
Hehe &amp;lt&amp;gt disappeared in the above code,<br>you can use these 3 char sequence to replace &amp;lt:<br>'&amp;' 'l' 't'<br>and '&amp;' 'g' 't' to replace &amp;gt<br>
 
咦?pega,贴错地方啦!?
 
看看正在讨论的 &nbsp;"类似 deltree xcopy 函数的讨论" &nbsp;
 
To dwwang:<br>?? Hehe, it's my first time to see this problem. And I remember<br>I attibute my comment onto another problem. That might be a little<br>bug, :)<br>
 
因为TShFileOpStruct的pFrom和pTo是PChar类型,所以它是以#0为结束标志。<br>做以下改动就可以了。<br>F.pFrom := 'D:/a.db'; &nbsp;-&gt; &nbsp;F.pFrom := 'D:/a.db'#0;<br>F.pTo := 'C:/b.db'; &nbsp; &nbsp;-&gt; &nbsp;F.pTo &nbsp; := 'c:/b.db'#0;<br>
 
谢谢各位!<br>按照各位建议,经过测试,我认为pegasus和houyg的答案可以接受,<br>本身有bug,但houyg的方法可解决。<br>问题讨论到此结束。<br>
 
Haha, I never join the discussion of this problem, but I got the lion's share, :)
 

Similar threads

顶部