HOME Delphi SaveToFile Print File I/O Status Check ShellExecute TJpegImage SMTP CreateFile SW_SHOW GetDriveType SendMail TBitmap SW_HIDE BMP to JPG ShowWindow TOSVERSIONINFO GetVolumeInformation TColor Transparent Text Out Is Audio CD TPrintDialog DelTree Print Dialog cmWhiteness Delphi Folder Navigation Dialog Animated Application Icon OS Version Information GetSystemDefaultLangID Animated Icon CopyFrom GetWindowsVersion Gradient Filled Form PC 켜져 있는 시간 알아내는 방법 Hide Caption Bar Hide Taskbar Paint Form long file name support Long Path Name Merge Files Open URL OPEN_EXISTING FILE_ATTRIBUTE_NORMAL confirm DateTimeToSystemTime Delphi File System Control Delphi Graphics and Drawing ChangeFileExt dwFileAttributes File Delete with UNDO File is in use FILE_ATTRIBUTE_DIRECTORY GENERIC_WRITE Filename conversion FileTimeToDosDateTime BrowseInfo 켜져있는시간 available memory size free memory free memory size free memory space

FILE I/O STATUS CHECK.ZIP

Checking If File Is In Use   (created at Sep 10, 2007)   55  

IsFileInUse will return true if the file is locked for exclusive access. It would fail if the file doesn't exist at all. function IsFileInUse(fName : string) : boolean;var    HFileRes : HFILE;begin    Result := false;    if no...

Convert a mapped drive to a full UNC path   (created at Sep 10, 2007)   89  

Universal/Uniform Naming Convention. A UNC path describes the location of a volume, directory, or file.The format for a UNC path is \servervolumedirectoryfile and is not case-sensitive. For example:    \Shared1_svrShared1WGroupsNetworkOrders.xlsR...

Does my CD-ROM drive contain an audio CD?   (created at Sep 10, 2007)   38  

We can use the Windows API function GetDriveType() to test if the drive is a CD-ROM drive then use the Windows API function GetVolumeInformation() to test if the VolumeName is 'Audio CD'.function IsAudioCD(Drive : char) : bool;var   DrivePath : s...

Delete files with the ability to UNDO   (created at Sep 10, 2007)   43  

Here's a Delphi procedure that can delete a file with the ability to undo by sending the file to the "Recycle Bin."Function FileDeleteRB will return True if the operation was successful.uses ShellAPI;function FileDeleteRB( AFileName:string): boolean;var St...

Delete folders recursively   (created at Sep 10, 2007)   40  

The following function completely deletes a directory regardless of whether the directory is filled or has subdirectories. No confirmation is requested so be careful. If the operation is successful then True is returned, False otherwise.Usageif DelTree('c:...

From/to the 8.3 (short) format to/from the long format   (created at Sep 10, 2007)   63  

This unit provides two functions that convert filenames from the long format to the 8.3 format, and from the 8.3 format to the long format.LFN_ALT.pasunit LFN_ALT;interfacefunction AlternateToLFN(AltName:String):String;function LFNToAlternate(LongName:Stri...

Get File 'Last Modified' attribute   (created at Sep 10, 2007)   51  

This function is useful to get file attribute.Usage:label1.Caption:=FileLastModified('c:autoexec.bat') ;In addition, below function must be included in order to use above function.function FileLastModified(const TheFile: string): string;var  FileH : T...

How to Split and Merge Files   (created at Sep 10, 2007)   64  

There are times when you need to split a large file into several smaller ones (for whatever the purpose is). The following two methods use Delphi TStream objects to break a file into several files with predefined size; and to merge those files back to the ...

Path shortener: c:ABC...DEF.ghi   (created at Sep 10, 2007)   67  

Sometimes when a huge path [any long string] is to be displayed in a small space, it is desirable to see the start and the end of the path with ellipses in-between, rather than truncating one of the ends.For example"C:Program FilesDelphiDDropTargetDemomain...

Reading a directory content   (created at Sep 10, 2007)   86  

The following example lists all files and subdirectories of the C:Windows directory into a TListBox called ListBox1:Usage:FindAll('C:Windows*.*',faAnyFile,ListBox1.Items)Followings are the source code for FindAll procedure.procedure FindAll (const Path: St...

Convert TColor to Hex & Hex to TColor   (created at Sep 10, 2007)   44  

Here are two simple functions to convert color values from TColor to Hex (HTML) and vice versa:function TColorToHex(Color : TColor) : string;begin   Result :=     IntToHex(GetRValue(Color), 2) +     IntToHex(GetGValu...

Convert a BMP to a JPG   (created at Sep 10, 2007)   40  

You can easily convert a BMP image to a JPG (JPEG) image:{Usage:BMPtoJPG('mybitmap.bmp','myjpeg.jpg')}function BMPtoJPG   (var BMPpic, JPGpic: string):boolean;var Bitmap: TBitmap;    JpegImg: TJpegImage;begin  Result:=False;  ...

Browse for Computers, Folders, Files and Printers   (created at Sep 10, 2007)   51  

By using the SHBrowseForFolder Windows API function and Delphi we can invoke a Windows system dialog used to browse for files and folders on users hard drive as well as network computers and printers. First, let's look at what SHBrowseForFolder needs. Here...

How to draw Transparent Text on bitmap   (created at Sep 01, 2007)   62  

You can set transparent mode by calling SetBkMode function.procedure TForm1.Button1Click(Sender: TObject);begin  with Image1.Picture.Bitmap.Canvas do  begin    Font.Color  := clBlue;    Brush.Style := bsclear;   ...

How Do I Remove The Application Icon From The Taskbar?   (created at Aug 25, 2007)   46  

To remove the icon from the taskbar, you need to call a Windows API call:BOOL ShowWindow(HWND hwnd,int nCmdShow);Delphi makes it very easy to use this command. All you need to do is supply the Application.handle and SW_HIDE to remove the icon from the task...

How To Show The Print Dialog And Print Text Files   (created at Aug 25, 2007)   71  

This code show an example of how to print a text of a RichEdit component.unit Unit1; interface uses   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,   StdCtrls, ComCtrls; type   TForm1 = class(TForm)     ...

How To Make An Animated Application Icon   (created at Aug 25, 2007)   80  

Show how to create an animated icon in your programvar  icon1:Boolean; ... procedure TForm1.Timer1Timer(Sender: TObject); begin   if icon1=false then   begin     Application.icon:=Image1.Picture.Icon;      icon1:=tru...

How To Pass The Focus To The Next/prior Control   (created at Aug 25, 2007)   70  

Shows how to activate the next or prior control in a formnext control: SendMessage(Form1.Handle, WM_NEXTDLGCTL, 0, 0); prior control: SendMessage(Handle, WM_NEXTDLGCTL, 1, 0);

How To Make Rounded Windows   (created at Aug 25, 2007)   51  

Create a different form in your application...procedure TForm1.FormCreate(Sender:TObject);  var    region: HRgn;  begin    region:=CreateEllipticRgn(1,1,200,200);    SetWindowRgn(handle, region, true);  end;

How To Get Windows Uptime   (created at Aug 25, 2007)   65  

Find how long Windows has been working...function UpTime: string; const ticksperday : integer = 1000 * 60 * 60 * 24; ticksperhour : integer = 1000 * 60 * 60; ticksperminute : integer = 1000 * 60; tickspersecond : integer = 1000; var  t : longword; &nb...

How To Find Out Total And Available Memory   (created at Aug 25, 2007)   44  

Get the total and available memory in your system. (Total free memory space in your system)procedure TForm1.Button1Click(Sender: TObject); var   memory:TMemoryStatus; begin   memory.dwLength:=sizeof(memory);   GlobalMemoryStatus(memory); &nb...

How To Change The System Time   (created at Aug 25, 2007)   56  

This code shows how to set the system time to another value.procedure TForm1.Button1Click(Sender: TObject); var    systemtime : TSystemTime;    NewTime:string; begin    NewTime:='13:58:00';    DateTimeToSystemTime( D...

How To Get The Windows OS Version   (created at Aug 25, 2007)   60  

 Identify the Windows version of your systemfunction GetWindowsVersion : string;  var    OsVinfo   : TOSVERSIONINFO;    HelpStr   : array[0..50] of char;  begin    ZeroMemory(@OsVinfo,sizeOf(OsVinfo));...

How To Change The Desktop Wallpaper   (created at Aug 25, 2007)   49  

Change the wallpaper of your system by codeuses    Registry, WinProcs;  procedure SetWallpaper(               sWallpaperBMPPath : String;               bTile : boolean );&...

How To Get The Windows Language   (created at Aug 25, 2007)   57  

Obtains the language that Windows is using.function Language:string;  var    sLangID:LangID;    sLanguage: array [0..100] of char;  begin    sLangID:=GetSystemDefaultLangID;    VerLanguageName(sLangID,sLang...

How To Make A Gradient Filled Form   (created at Aug 25, 2007)   49  

Show how to paint a form in a different way...procedure TForm1.FormPaint(Sender: TObject); var   Row, Ht: Word;   IX: Integer; begin   iX :=200 ;   Ht:=(ClientHeight + 512) div 256;   for Row := 0 to 512 do   begin   &nbs...

How can I hide the caption bar on a form?   (created at Aug 25, 2007)   41  

To hide the caption bar you need to override on of the default form methods CreateParams (this also exists for other objects).The CreateParams method initializes a window-creation parameter record passed in the Params parameter (ref:Delphi Help).Go to the ...

How To Send An E-mail By Code   (created at Aug 25, 2007)   40  

Use this function to send an e-mail through your program. You must have the component TNMSMTP from FastNet tools. This component is included in Delphi 4-5 Professional and Enterpriseprocedure TForm1.Button1Click(Sender: TObject); begin   NMSMTP1.Host ...

How To Open Url In Default Webbrowser   (created at Aug 25, 2007)   52  

Use this function to open your browser with a given URL.uses    shellapi;  ....  procedure TForm1.Label1Click(Sender:TObject);  begin    shellexecute(handle,'open','http://www.swissdelphicenter.ch', nil,nil,sw_show); ...

How To Check If A Soundcard Is Installed   (created at Aug 25, 2007)   56  

Use this code to verify if a soundcard is installed in your systemuses mmsystem;  ...  function Soundkarte:Boolean;  begin    Result := WaveOutGetNumDevs >0;  end;