Arsip

Archive for Mei, 2008

When was that file last accessed?

Here’s an example of how to write a function that’ll return a file’s last access time (not to be confused with the last modified time). Baca selanjutnya…

Iklan
Kategori:Delphi

Triggering default menu items from code

Mei 12, 2008 2 komentar

It’s sometimes useful to be able to trigger the default menu item of a popup menu from code. Here is a routine that does just that for any popup menu.

Kategori:Delphi

Search for help

Mei 12, 2008 2 komentar

Looking for a way to open your application’s help file to it’s search window? All you have to do is pass the name (and the path) of your help file and the string you want to search for to the following HelpSearch() function: Baca selanjutnya…

Kategori:Delphi

Reading and writing INI files

Mei 12, 2008 1 komentar

Here is an overloaded group of commands to read from or write to an INI file. The routines are overloaded based on the d parameter. s is the [GROUP], k is Left side (key), d is the default or new parameter and f is the filename to use. Baca selanjutnya…

Kategori:Delphi

Open documents and URLs in their associated applications

If you like how Windows Explorer and File Manager lets you open documents just by double clicking on them, without opening the associated program first, here’s how to achieve similar functionality from your Baca selanjutnya…

Kategori:Delphi

Message box that works with a Delphi Service Application

Here is a message box that you can display from service applications. Change MB_OK to alter the buttons that appear. If you want the return value from MessageBoxEx change PopServiceBox into a function.

procedure PopServiceBox(Title, Text: string);
begin
  MessageBoxEx(
    0, PChar(Text), PChar(Title),
    MB_OK or MB_TOPMOST or MB_SERVICE_NOTIFICATION, 0
  );
end;
Kategori:Delphi

Merging filesMerging files

The following routine merges a file of files specified in a string list (Files) into a single target file (TargetFile whose name is specified as a string. Note TargetFile should not also be in Files or an error will be reported.

procedure MergeFiles(const Files: TStrings; const TargetFile: string);
var
  I: Integer;
  InStm, OutStm: TFileStream;
begin
  OutStm := TFileStream.Create(TargetFile, fmCreate);
  try
    for I := 0 to Pred(Files.Count) do
    begin
      InStm := TFileStream.Create(Files[I], fmOpenRead);
      try
        OutStm.CopyFrom(InStm, 0);
      finally
        InStm.Free;
      end;
    end;
  finally
    OutStm.Free;
  end;
end;
Kategori:Delphi