Building a Simple DNS Server in Delphi with TTL Support Below is a basic Delphi code example to implement a DNS server capable of handling A, AAAA, CNAME, and TXT records with Time-To-Live (TTL) support. This example uses the IdUDPServer component from Indy (Internet Direct) library for handling UDP packets.Thi... |
Run command with Administrator permission in Delphi on Microsoft Windows In Delphi, you can execute commands with administrator privileges by using the ShellExecute function with the 'runas' verb. However, if you want to execute a specific command with administrator privileges, you can use the CreateProcess function from the Wi... |
Get Application Data Path on Delphi In case of getting application data path on delphi like C:Documents and Settings[username]Application Data', you can use following function. |
How to get application version number in Delphi If you need to get application version number at runtime, you can get it by calling below sample code. |
How To Turn On/Off Monitor with Delphi In case that you need to shutdown the monitor to conserver power during program execution, you can simple turn your monitor off by calling below function. If you need to turn your monitor on, you can do it by calling below function. Final tip to ... |
Run PowerShell Command as Administrator in Delphi To capture the output of the PowerShell command and store it in a string variable, you can modify the RunPowerShellCommandAsAdmin procedure to redirect the output of the PowerShell process and read it into a string. In this modified code:We create a T... |
Delphi code to send data to web server based on POST method To send content using the POST method in Delphi, you can use the TIdHTTP component from the Indy library, which is a popular library for internet components in Delphi. Below is an example Delphi code snippet demonstrating how to send content using the POST... |
Delphi Program can command level execution program with hidden mode Below is the example of running command with hidden mode. Actually there lots of command type in Windows like SW_NORMAL, SW_HIDE, ...What I am going to implement is running windows command with hidden mode.Below is the example of windows command execution ... |
Get the length of arrays and a string The length function returns either the number of characters in Source String, or the number of elements in Source Array.Notes: Arrays start at index=0 by default, So the length of such an array is 1 more than the highest index.Following is the simple examp... |
How to return exit code such as exit() function in C/C++ ? You can return exit code in delphi by following method: As you can see above, you can set exit code by ExitCode variable. That is global variable indicating exit code. |
Good Delphi components JVCL source code that can be obtained from http://jvcl.sourceforge.net JCL source code that can be obtained from http://jcl.sourceforge.net Virtual TreeView than can be obtained from http://www.delphi-gems.com/VirtualTreeview Delphi Chromium Embedded 3 tha... |
How to download/grap web pages or XML document at internet website in Delphi XE? If you are considering Delphi XE as cross compiler for the multiple platforms such as Android, iOS, and Windows, you need to have the standard method to get web content such as the normal text, or XML document as a result of RESTful API.Delphi provides the... |
The Delphi function to get My Videos folder In order to get My Videos folder, you need to call SHGetSpecialFolderPath(). But I recommend you to use below wrapper for easy control.function GetSpecialFolderPath(Folder: Integer; CanCreate: Boolean): string;// Gets path of special system folders//// Cal... |
I want to select directory(folder) not file. How can I do that ? Delphi provides function for directory(folder) selection as following.uses FileCtrl;var dir : string;begin if SelectDirectory(dir, [sdAllowCreate, sdPerformCreate, sdPrompt], 0) then begin m_directory.Text := dir;... |
Changing the Title of a Print Dialog in Delphi The TPrintDialog component displays a standard Windows dialog box for sending jobs to a printer. Unfortunately, the TPrintDialog does not expose the Title property. By handing the OnShow event of a print dialog you can specify the text for the dialog’s tit... |
Auto Logon Programming in Delphi In case that you need to develop auto logon application based on Windows operating system. You need to access windows registry. Refer below Delphi based example. (autologon.dpr) If you want to compile above sample code, just copy & paste as autologon.dpr a... |
Thread Application Implementation in TThread Delphi provides class for thread application as TThread.Following is the simple example for thread application.type TForm1 = class(TForm) Memo1: TMemo; GroupBox1: TGroupBox; seTimeToWork: TSpinEdit; ... |
Is there directory selection VCL component in Delphi ? There are FileOpenDialog and FileSaveDialog components on Delphi VCL.Sometimes you may need directory selection dialog, but no components are found on VCL.Do you know Delphi provides the solution as SelectDirectory().Here are two examples for directory sel... |
How to launch application ? You can launch application on windows by ShellExecute function. Following is the simple example to launch application.use ShellAPI;...ShellExecute(Handle, 'open', PChar('c: estapp.exe'), nil, nil, SW_SHOW);In case of running DOS command application such as... |
How to print external document ? Without complex programming, you can print document by ShellExecute function.use ShellAPI;...ShellExecute(Handle, 'print', PChar('c: est est.doc'), nil, nil, SW_SHOW); |
Delphi API to get windows temporary directory When you need to access windows temp directory, you can get from environment variables.Following is the example to get temporary directory.var m_tempdir: string... m_tempdir := GetEnvironmentVariable('TEMP'); |
Delphi API to get the current working directory You can get the current working directory information by GetCurrentDir function.Following is the usage example:var m_curdir:string...m_curdir := GetCurrentDir; |
How to resize PNG file in Delphi ? In case that you need to change PNG file size (width, height), you can use below function. procedure copy_to_resized_png( tar, src:string; w, h: Integer); var bmp: TBitmap; png, output: TPngImage; begin &nb... |
Delphi Pointer Types Sometimes, you may confuse the name of the pointer type in delphi, because of the difference with C/C++. It's really make us confusion. Actually usage rule is also different, so I always forget how to use delphi pointer easily.Anyway below table is useful ... |
How to read/wrtie INI file in Delphi ? Delphi provides useful function to access INI file. With TIniFile class, you can read and write easily.Below is the simple example writing INI files.uses inifiles;...procedure Tform1.Button1Click(Sender:TObject);var myIniFile:TIniFile;begin myI... |
How to get file created time, modified time, and last accessed time ? In order to get the file attributes, you can get it by file search API.Here's an example of how to show the creation, last access and last modification dates and times of a file: |
Delphi string conversion functions - AnsiToUTF-8, UTF8Encode, ... Delphi already provide string conversion functions variously. You just call conversion function.function UnicodeToUtf8(Dest: PChar; Source: PWideChar; MaxBytes: Integer): Integer; overload; deprecated;function Utf8ToUnicode(Dest: PWideChar; Source: PChar; ... |
When subject is crashing in TIdSMTP VCL In case of using Delphi 2009 with Indy 10, when I try to send an email with TIdSMTP, on the received email this text arrived as questions marks '?????'.This is caused by TIdSMTP VCL bug.You can fix it by upgrading Indy10 at ftp://indy.fulgan.com/ZIP. Pleas... |
How to send text/html based email in UTF-8 with TIdSMTP, TIdMessage VCL I had problem in encoding mail header with IdSMTP, IdMessage. I found some references in Internet, but the problem is the delivered mail subject is always filled with question marks except english letters.I found the answer to clear the problem. Here's the... |
How to encode subject content when sending mail with TIdMessage ? Today, I tried to develop mail application with TIdMessage, but I have problem in character set encoding. And I found the answer at http://www.yac.com.pl/mt.texts.tidmessage.charset.en.htmlWith this wrapper class, TMyMessage = class(TIdMessage) ... |