unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  teste: WideString;
const
  BOM = #$FF#$FE;
begin

  with TFileStream.Create(ExtractFilePath(Application.ExeName)+'\teste.udl', fmCreate) do
  try
    teste :=
      '[oledb]'+#13#10+
      '; Everything after this line is an OLE DB initstring'+#13#10+
      'Provider=MSDASQL.1;Persist Security Info=False;Data Source=dBASE Files';
    //você sabe que o BOM tem um tamanho fixo, que é 2 bytes. O bom é um único widechar de 2 bytes
    Write(BOM, 1 * sizeof(widechar)); //2
    Write(Pointer(teste)^, Length(teste)*SizeOf(WideChar));
  finally
    Free;
  end;

end;



end.
