Вторник, 29.09.2026, 10:15
Вы вошли как Гость | Группа "Гости"Приветствую Вас Гость | RSS
Форма входа
Меню сайта
Главная » FAQ [ Добавить вопрос ]

Программирование Delphi [91]
Вопрос-Ответ по программированию

Используйте функцию SHAddToRecentDocs.
Пример :

 
             uses ShlOBJ;  
             procedure TForm1.Button1Click(Sender: TObject); 
             var 
               s : string; 
             begin 
               s := 'C:\DownLoad\ntkfaq.html'; 
               SHAddToRecentDocs(SHARD_PATH, pChar(s)); 
             end; 
Добавил: casperof

Используйте метод SetPrinter класса TPrinter.
Пример :

 
             uses Printers; 
 
             {$IFNDEF WIN32} 
              const MAX_PATH = 144; 
             {$ENDIF} 
 
             procedure TForm1.Button1Click(Sender: TObject); 
             var 
               pDevice : pChar; 
               pDriver : pChar; 
               pPort   : pChar; 
               hDMode : THandle; 
               PDMode : PDEVMODE; 
             begin 
               if PrintDialog1.Execute then begin 
                 GetMem(pDevice, cchDeviceName); 
                 GetMem(pDriver, MAX_PATH); 
                 GetMem(pPort, MAX_PATH); 
                 Printer.GetPrinter(pDevice, pDriver, pPort, hDMode); 
                 Printer.SetPrinter(pDevice, PDriver, 'FILE:', hDMode); 
                 FreeMem(pDevice, cchDeviceName); 
                 FreeMem(pDriver, MAX_PATH); 
                 FreeMem(pPort, MAX_PATH); 
                 Printer.BeginDoc; 
                 Printer.Canvas.TextOut(100, 100, 'Delphi Is RAD!'); 
                 Printer.EndDoc; 
               end; 
             end;
Добавил: casperof

             type 
               TForm1 = class(TForm) 
                 Button1: TButton; 
               private 
                 { Private declarations } 
                 procedure WMDeviceChange(var Message: TMessage); 
                   message WM_DEVICECHANGE; 
               public 
                 { Public declarations } 
               end; 
 
             var 
               Form1: TForm1; 
 
             implementation 
 
             {$R *.DFM} 
 
             const DBT_DEVICEARRIVAL = $8000; 
             const DBT_DEVICEQUERYREMOVE = $8001; 
             const DBT_DEVICEQUERYREMOVEFAILED = $8002; 
             const DBT_DEVICEREMOVEPENDING = $8003; 
             const DBT_DEVICEREMOVECOMPLETE = $8004; 
             const DBT_DEVICETYPESPECIFIC = $8005; 
             const DBT_CONFIGCHANGED = $0018; 
 
             procedure TForm1.WMDeviceChange(var Message: TMessage); 
             var 
               s : string; 
             begin 
             {Do Something here} 
               case Message.wParam of 
                 DBT_DEVICEARRIVAL : 
                   s := 'A device has been inserted and is now available'; 
                 DBT_DEVICEQUERYREMOVE: begin 
                   s := 'Permission to remove a device is requested'; 
                   ShowMessage(s); 
                  {True grants premission} 
                   Message.Result := integer(true); 
                   exit; 
                 end; 
                 DBT_DEVICEQUERYREMOVEFAILED : 
                   s := 'Request to remove a device has been canceled'; 
                 DBT_DEVICEREMOVEPENDING : 
                   s := 'Device is about to be removed'; 
                 DBT_DEVICEREMOVECOMPLETE : 
                   s := 'Device has been removed'; 
                 DBT_DEVICETYPESPECIFIC : 
                   s := 'Device-specific event'; 
                 DBT_CONFIGCHANGED : 
                   s:= 'Current configuration has changed' 
                 else s := 'Unknown Device Message'; 
               end; 
               ShowMessage(s); 
               inherited; 
             end; 
 
Добавил: casperof

Вызовите функцию WriteProfileString() или WritePrivateProfileString(), передав ей в качестве параметров секции, ключа и строки - nil.
Пример
:

                WriteProfileString(nil, nil, nil); 
 
              WritePrivateProfileString(nil, nil, nil, FileName); 
Добавил: casperof

             uses ShellApi; 
 
             procedure TForm1.Button1Click(Sender: TObject); 
             begin 
               ShellExecute(0, 
                            'explore', 
                            'C:\WINDOWS', 
                            nil, 
                            nil, 
                            SW_SHOWNORMAL); 
             end; 
Добавил: casperof

Наш опрос
С какого поисковика вам стал известен сайт?
Всего ответов: 28
Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0
Поиск