Advertisement
miguelhosttimer

criar um txt area de trabalho

May 15th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.98 KB | None | 0 0
  1.     unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, ShlObj;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     procedure Button1Click(Sender: TObject);
  13.   private
  14.     { Private declarations }
  15.   public
  16.     { Public declarations }
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.dfm}
  25.  
  26. procedure TForm1.Button1Click(Sender: TObject);
  27. var
  28.   ArquivoTexto: TStringList;
  29.   CaminhoAreaTrabalho: array[0..MAX_PATH] of Char;
  30.   i: Integer;
  31. begin
  32.   ArquivoTexto := TStringList.Create;
  33.   try
  34.     for i := 1 to 55 do
  35.     begin
  36.       ArquivoTexto.Add('Linha ' + IntToStr(i));
  37.     end;
  38.  
  39.     if SHGetFolderPath(0, CSIDL_DESKTOP, 0, SHGFP_TYPE_CURRENT, CaminhoAreaTrabalho) = S_OK then
  40.     begin
  41.       ArquivoTexto.SaveToFile(StrPas(CaminhoAreaTrabalho) + '\arquivo.txt');
  42.     end;
  43.   finally
  44.     ArquivoTexto.Free;
  45.   end;
  46. end;
  47.  
  48. end.
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement