在2000下使用TSHFileOpStruct 时,有时行有时不行,为什么?(50分)

  • 主题发起人 主题发起人 xxxyyyuuu
  • 开始时间 开始时间
X

xxxyyyuuu

Unregistered / Unconfirmed
GUEST, unregistred user!
TSHFileOpStruct fos;<br>&nbsp; &nbsp; char *buf1=new char[128];<br>&nbsp; &nbsp; char *buf2=new char[128];<br>&nbsp; &nbsp; AnsiString Str1,Str2;<br>&nbsp; &nbsp; Str1= edit_db_target-&gt;Text;<br>&nbsp; &nbsp; if (savedlg-&gt;Execute())<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; if (savedlg-&gt;FileName!="")<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str2=savedlg-&gt;FileName;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(buf1,Str1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(buf2,Str2);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fos.hwnd=Application-&gt;MainForm-&gt;Handle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fos.wFunc=FO_COPY;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fos.pFrom=buf1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fos.pTo=buf2;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fos.fFlags= FOF_SIMPLEPROGRESS;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fos.fAnyOperationsAborted=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fos.hNameMappings=NULL;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fos.lpszProgressTitle="正在备份文件...";<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SHFileOperation(&amp;fos);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; //delete savedlg;<br>&nbsp; &nbsp; delete []buf1;<br>&nbsp; &nbsp; delete []buf2; */
 
msdn<br><br>PRB: File Names Truncated When Using SHFileOperation <br><br>Q186152<br><br><br>--------------------------------------------------------------------------------<br>The information in this article applies to:<br><br>Microsoft Win32 Software Development Kit (SDK), on platform(s):<br>Microsoft Windows 95 <br>The Microsoft Windows NT operating system <br>The Microsoft Windows 2000 operating system<br><br>--------------------------------------------------------------------------------<br><br><br>SYMPTOMS<br>When you use SHFileOperation to copy or move files, the destination file names are truncated to the 8.3 file name format. For example, the file name "New Document.temp" will be truncated to "NewDocum.tem". <br><br><br><br>CAUSE<br>The default behavior of SHFileOperation causes this problem. This behavior only occurs when you use a relative path for the destination. <br><br><br><br>RESOLUTION<br>Use a full path instead of a relative path for the destination. <br><br><br><br>STATUS<br>This behavior is by design. <br><br>Additional query words: <br><br>Keywords : kbLib kbOSWinNT400 kbOSWin2000 kbSDKWin32 kbOSWin95 kbGrpShell <br>Issue type : kbprb <br>Technology : kbOSWinNT kbOSWinSearch <br><br><br>Last Reviewed: October 21, 2000<br>&amp;copy; 2001 Microsoft Corporation. All rights reserved. Terms of Use.<br>&nbsp;<br><br><br>
 
注意buf1,buf2必须至少比Str1,Str2的长度大2,因为他们必须用2个0结束字符串<br><br>StrPCopy(buf1,Str1);<br>buf1[Str1.Length()+1]=0;<br>StrPCopy(buf2,Str2);<br>buf2[Str2.Length()+1]=0;<br>
 
接受答案了.
 
后退
顶部