Delphi HTTP POST JSON Example

Here is an example to POST JSON data with Delphi 10: Reference: https://stackoverflow.com/a/24042633 Add these libraries in your uses: idSSLopenSSL, idHttp, JsonidSSLopenSSL, idHttp, Json Here is the example code to POST JSON data: procedure TForm1.Button1Click(Sender: TObject); var JsonStr: string; sResponse: string; JsonToSend: TStringStream; HTTP1: TidHTTP; F: TJSONObject; begin Button1.Enabled := False; memoResponse.Lines.Clear; memoRequest.Lines.Clear;   F […]

How to Send (POST) JSON Data with PHP cURL

Example PHP code to send (via HTTP POST) JSON data to an URL: $data = array( "username" => "admin", "password" => "password", );   $curl = curl_init("https://api.website.com/v1/auth/login/"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLINFO_HEADER_OUT, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’); $output = curl_exec($curl); curl_close($curl);   print_r(json_decode($output));$data = array( "username" => "admin", "password" […]

PCRE Fnmatch() PHP Function for Wildcard String Match

PHP function fnmatch() has 4096 characters limit: Warning: fnmatch(): Filename exceeds the maximum allowed length of 4096 charactersWarning: fnmatch(): Filename exceeds the maximum allowed length of 4096 characters To avoid these limits we can use a PCRE-like fnmatch() function: https://www.php.net/manual/en/function.fnmatch.php#100207 Here is a modified PHP code found in the php.net website: if (!function_exists(‘fnmatch’)) { define(‘FNM_PATHNAME’, […]

Delphi XE Add Icons and Images as Resources

First Click on Project -> Resources and Images: Then just click on “Add” to add an icon or image: For icons, make sure to use all UPPERCASE characters. Here is an example to use a icon resource in the trayicon: procedure TForm1.Button4Click(Sender: TObject); begin TrayIcon1.Visible := False; TrayIcon1.Icon.LoadFromResourceName(hInstance, ‘ICON1’); TrayIcon1.Visible := True; end;procedure TForm1.Button4Click(Sender: TObject); […]

Delphi XE Change System Tray Icon with TTrayIcon (No Blurry)

You can change system tray icon by using TTrayIcon and TImageList: procedure TForm1.Button4Click(Sender: TObject); begin TrayIcon1.IconIndex := 0; end;   procedure TForm1.Button5Click(Sender: TObject); begin TrayIcon1.IconIndex := 1; end;procedure TForm1.Button4Click(Sender: TObject); begin TrayIcon1.IconIndex := 0; end; procedure TForm1.Button5Click(Sender: TObject); begin TrayIcon1.IconIndex := 1; end; However this seems to add a blurry effect on the icon (not […]

Visual C++ Redistributable Runtimes All-in-One

From this link you can download all VC++ redistributable runtimes: Download Visual C++ Redistributable Runtimes All-in-One Extract the ZIP and right-click on install.bar -> Run as Administrator File size is ~85 MB and works on XP/7/8/10 32/64-bit.

Download cURL & Libcurl 7.46 for Windows XP

Are you looking for cURL 7.46 that works on the old Windows XP SP3 X86? Here you can download all compiled mingw cURL 7.* versions: https://bintray.com/vszakats/generic/curl/ And here you can download cURL 7.46 version that works on Windows XP: https://bintray.com/vszakats/generic/curl/7.46.0 You need to select the “curl-7.46.0-win32-mingw.7z” file: Direct download for curl-7.46.0-win32-mingw.7z (Local mirror) curl-7.46.0-win32-mingw.7z Another […]

Determine Windows Version with InnoSetup

If you need to install a file on say XP or Vista and newser: [Files] Source: MyDllForVistaAndNewer.dll; Dest: {app}\MyDll.dll; MinVersion: 6.0 Source: MyDllForOldWindows.dll; Dest: {app}\MyDll.dll; OnlyBelowVersion: 6.0[Files] Source: MyDllForVistaAndNewer.dll; Dest: {app}\MyDll.dll; MinVersion: 6.0 Source: MyDllForOldWindows.dll; Dest: {app}\MyDll.dll; OnlyBelowVersion: 6.0 Here are some functions to use inside [Code]: function IsWindowsVersionOrNewer(Major, Minor: Integer): Boolean; var Version: TWindowsVersion; […]

Windows Registry Keys used to Get VC_Redist Version Installed

To check if VC_Redists are installed you can check these Windows registry keys: *** Tested on Windows Vista, 7, 8, 8.1 and Windows 10 (2004 Build) *** *** WARNING: On Windows XP the registry key is different *** To install X86 VC++ Redistributables in a Win64 OS: [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum] "Install"=dword:00000001 "InstallerType"="MSI" "SP"=dword:00000000 "SPIndex"=dword:00000000 "SPName"="RTM" "Version"="14.20.27508" "UpdateVersion"="14.20.27508"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum] […]