CreateFile.zip

I want to select directory(folder) not file. How can I do that ?

614

Delphi provides function for directory(folder) selection as following. The above function is tested on Delphi 2009,but UI is more like windows 3.1.So I recommend you to use below function which calls shell API on Microsoft Windows System.

How to get get IE favorites

448

The GetIEFavourites function called from the OnClick event of a button returns a list of all the favorites from your Internet Explorer in a ListBox.

Browse for Computers, Folders, Files and Printers

570

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's...

Find File at certain directory in Delphi

434

This function we show below receives as parameters a file specification (like for example 'C: mp*.tmp' or 'C:*' if you want to search the entire hard disk.) and optionally a set of attributes (exactly as Delphi's FindFirst function),and it returs a StringL...

How to save text from Clipboard to a file

564

If you want to save the text data contained in the Clipboard to a text file on a disk, use the next code:{Usage:ClipboardTxtToFile(c:dircliptext.txt)}uses Clipbrd;function ClipboardTxtToFile         (sFileTXT : string) : boolean;va...

How to send char as message to another application

536

The following code is used to insert a character into another application - Notepad.Sending a Character to Another Application (Notepad):Understanding the Code: This code snippet utilizes Windows API functions to send a character ('A') to the Notepad appli...

How to restrict mouse movement

405

Here's how to restrict the mouse movement to a form and release this restriction after a click on a form: .Restricting Mouse Movement in a Form (Delphi)This code snippet demonstrates how to restrict the mouse cursor to a specific form in Delphi.Here's a br...

List Devices (LPT, COM ports, ...)

477

The following procedure will list all the devices on your computer.You can then extract the com ports and printer ports by looking for the 'COM' and 'LPT' characters in the list.Add a Memo and a Button and place this code in the OnClick of a button….

How to know whether the font is TrueTypeFont or not

373

Given a font's name (such as Arial,Verdana, Times New Roman, etc), function returns a boolean value indicating whether the font is or isn't a True Type font.function IsTrueTypeFont(FontName : string):boolean;const  PITCH_MASK: byte = $0F;var  TxM...

How to track a user's idle time

587

Suppose you have a data-critical type of application where you would not want a non-authored user to work with the data.Such an application could automatically log out the current user if no user activity has taken place in a lengthy time.To track a user's...

How to determine the output of a console application ?

449

When you write a console mode application (no GUI), the output by default goes to the screen, but this can be overridden by the process starting the app (see: How to capture the output from a console mode application).Use the code below to find where the o...

Get dimensions of usable space on monitor (work area)

486

If you need to find the dimensions of user's screen in pixels, after subtracting any space occupied by the task bar and any tool bars that sit on the desktop, use the WorkAreaHeight adnd WorkAreaWidth properties of the TScreen object. The following code de...

How to Get Filenames from Clipboard ?

1,500

"If I use the Windows Explorer to copy a file,how can I use the paste function in my application?" .This code retrieves the filenames from the clipboard to a memo component.Drop a memo and a button on a form and set the OnClick of a button to: .

Disable ALT+TAB, CTRL+ESC, CTRL+ALT+DEL

1,819

If you wish to disable those key combinations while your application is running call SystemKeys.When you call SystemKeys,if Disable is True,the keys will be disabled,False otherwise.Note: the code does NOT work under Win NT systems (XP,2000).

Disable Mouse and Keyboard from Delphi Code

787

The BlockInput API function blocks keyboard and mouse input events from reaching applications.Place a Button (name: "Button1") on a form (name: "Form1") and use this code for the button's OnClick event handler.Once you click the button your mouse and keybo...

Detecting Drive Types

467

Here's how to get the types of drives on your computer: / / Note: you will need one button and / / one memo on your form, for this tip... procedure TForm1.Button1Click(Sender: TObject) ; var   Drive: Char;   DriveLetter: String[4]; begin &nbs...

Detecting and preventing Windows shut down

432

When Windows is about to shut down,it sends a WM_QueryEndSession to all open applications.To detect (and prevent shutdown) ,we must define a message handler to this message.Put this definition on the private section of the main form:Also,to prevent Windows...

How to Close Another Application by Windows Caption

384

To programmatically close another application, send to the application a WM_QUIT message. "Window caption" is the caption of the window that you are sending the message to. Usage: if not KillApp('Window caption') then ShowMessage('App not closed') ;Here's ...

How to Change the Windows Start button bitmap

421

Here's how to chane the bitmap on the Windows Start button:{We'll need several global variables}var    Form1: TForm1;    StartButton : hWnd;    OldBitmap : THandle;    NewImage : TPicture;...{Now, we put this code in...