Y
yangdear
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
ErrorMessage: Pointer; // holds a system error string
ErrorCode: DWORD; // holds a system error code
begin
{blank out the status bar}
StatusBar1.SimpleText:='';
{attempt to copy the file}
CopyFile(PChar('//yxhserver/databak/databak.bak'),
PChar('d:/asda.bak'),
false);
{if the file was not copied, display the error message}
ErrorCode := GetLastError;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM,
nil, ErrorCode, 0, @ErrorMessage, 0, nil);
StatusBar1.SimpleText:='Error Copying File: '+string(PChar(ErrorMessage));
LocalFree(hlocal(ErrorMessage));
end;
ErrorMessage 的值是“操作成功”
var
ErrorMessage: Pointer; // holds a system error string
ErrorCode: DWORD; // holds a system error code
begin
{blank out the status bar}
StatusBar1.SimpleText:='';
{attempt to copy the file}
CopyFile(PChar('//yxhserver/databak/databak.bak'),
PChar('d:/asda.bak'),
false);
{if the file was not copied, display the error message}
ErrorCode := GetLastError;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM,
nil, ErrorCode, 0, @ErrorMessage, 0, nil);
StatusBar1.SimpleText:='Error Copying File: '+string(PChar(ErrorMessage));
LocalFree(hlocal(ErrorMessage));
end;
ErrorMessage 的值是“操作成功”