unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
ADOCommand1: TADOCommand;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
str:string;
begin
str:= format('DECLARE @cmd sysname'#13#10'SET @cmd = ''dir %s > c:/2.txt'' '#13#10'EXEC master..xp_cmdshell @cmd',['c:']);
showmessage(str);
ADOCommand1.CommandText:=str;
ADOCommand1.Execute;
end;
end.
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object BitBtn1: TBitBtn
Left = 200
Top = 200
Width = 75
Height = 25
Caption = 'BitBtn1'
TabOrder = 0
OnClick = BitBtn1Click
end
object ADOCommand1: TADOCommand
ConnectionString =
'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initi' +
'al Catalog=LCIS2.0'
Parameters = <>
ParamCheck = False
Left = 152
Top = 104
end
end