Delphi

Get & Set Audio Volume programmatically

Get & Set Audio Volume programmatically unit uMain; interface uses Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs, ExtCtrls,StdCtrls, mmsystem; //You must add this in the uses line type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure […]

Delphi

How to set the screen resolution programmatically

// How to set the screen resolution. procedure SetResolution(XRes, YRes: DWord); var lpDevMode : TDeviceMode; begin EnumDisplaySettings(nil, 0, lpDevMode); lpDevMode.dmFields := DM_PELSWIDTH or DM_PELSHEIGHT; lpDevMode.dmPelsWidth := XRes; lpDevMode.dmPelsHeight := YRes; ChangeDisplaySettings(lpDevMode, 0); end;

Delphi

Remove Dead Tray Icons

// Remove Dead Tray Icons procedure RemoveDeadIcons(); var TrayWindow : HWnd; WindowRect : TRect; SmallIconWidth : Integer; SmallIconHeight : Integer; CursorPos : TPoint; Row : Integer; Col : Integer; begin // Get tray window handle […]

Delphi

Hide start menu

// Hide start menu procedure HideStartMenu(); begin MoveWindow(FindWindowEx(FindWindow(‘shelltray_wnd’, nil), 0, nil, ‘button’), 0, 100, 10, 10); end;

Delphi

Get Executable Full Name From Window Handle programmatically

(* ——————————————– Get Executable Full Name From Window Handle — Required unit: Tlhelp32 ——————————————– *) function GetExeNameFromWindowHandle(AParent : HWND) : String; var ProcessEntry32 : TProcessEntry32; ProcessId : DWord; SnapshotHandle : Integer; begin Result := ”; […]

Delphi

Check & Register File Association programmatically

Check & Register File Association programmatically unit file_association; interface uses SysUtils, Registry, WinTypes, ShellAPI; function RegisterAssociation(const aExeName, aFileExt, aFileDesc, aFileIcon: string): Boolean; function ShellFindExecutable(const FileName, DefaultDir: string): string; implementation //————————————————————————// function RegisterAssociation(const aExeName, aFileExt, aFileDesc, […]

Delphi

How to Empty Recycle Bin programmatically

How to Empty Recycle Bin programmatically unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, ShellApi,Controls, Forms, Dialogs,StdCtrls, ExtCtrls; type TForm1 = class(TForm) procedure EmptyRecycleBin(); end; var Form1: TForm1; function SHEmptyRecycleBin(Wnd:HWnd; LPCTSTR:PChar; DWORD:Word):Integer; stdcall; const […]

Delphi

Retrieving System CPU Information programmatically

(* ———————————————– Retrieve various informations about the CPU like: brand id, factory speed, which instruction set supported etc. Author: Leslie Tailor ———————————————– *) unit main; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, […]

Delphi

Get Windows Uptime Information programmatically

Get Windows Uptime Information programmatically unit Unit_Procs; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms; (* declare functions *) function GetTickCount: LongInt; external ‘Kernel32.dll’; //gettickcount declaration function GetUptime: string; //format ticks into days, […]

Delphi

Deleting Registry Key from .Reg file

———————————— Deleting Registry Key from .Reg file ———————————— If you want to import a key but delete another key at the same time, use the syntax in your Reg file : [-HKEY_CURRENT_USERSoftwareLocal Applications] Note the […]

Delphi

Remove an entry from a registry key

Remove an entry from a registry key procedure RemoveFromRunKey(AppTitle : string); var i : integer; sKey : string; Reg : TRegistry; ListOfEntries : TStringList; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_LOCAL_MACHINE; sKey := ‘Software\Microsoft\Windows\CurrentVersion\Run’; […]

Database

Select a random datarecord

Select a random datarecord procedure TForm1.FormCreate(Sender: TObject); begin Randomize; end; procedure TForm1.Button1Click(Sender: TObject); begin Table1.First; Table1.MoveBy(Random(Table1.RecordCount)); end;

Database

Add a password to a paradox table

Add a password to a paradox table uses Bde, SysUtils, dbtables, windows; function StrToOem(const AnsiStr: string): string; begin SetLength(Result, Length(AnsiStr)); if Length(Result) 0 then CharToOem(PChar(AnsiStr), PChar(Result)); end; function TablePasswort(var Table: TTable; password: string): Boolean; var […]

Database

BDE Error list

BDE Error list: $0000 (0) = Successful completion. $0021 (33) = System Error $0022 (34) = Object of Interest Not Found $0023 (35) = Physical Data Corruption $0024 (36) = I/O Related Error $0025 (37) […]

Database

Show a TTable’s deleted records

Show a TTable’s deleted records procedure DeletedRecords(Table: TTable; SioNo: Boolean); begin Table.DisableControls; try Check(DbiSetProp(hDBIObj(Table.Handle), curSOFTDELETEON, Longint(SioNo))); finally Table.EnableControls; end; Table.Refresh; end;

Database

Undelete a dBASE record

Undelete a dBASE record procedure RecordUndelete(aTable: TTable); begin aTable.UpdateCursorPos; try Check(DbiUndeleteRecord(aTable.Handle)); except ShowMessage(‘No undelete performed.’); end; end;

Database

Save a Formula One spreadsheet to a blob field

Save a Formula One spreadsheet to a blob field uses vcf1, dbtables; procedure SaveSpreadsheet(F1Book: TF1Book); var BlobStream: TBlobStream; MyBlob: HGlobal; pblob: Pointer; begin with Datamodule1.Query1 do begin Set8087CW($133f); try Application.ProcessMessages; F1Book.SaveWindowInfo; MyBlob := GlobalAlloc(GMEM_MOVEABLE, 2000); […]

Database

Remove a dbase index flag

Remove a dbase index flag function UnCheckIndex(FileDbf: string): Boolean; var Dbf: file; Car: Char; begin Result := T; AssignFile(Dbf, FileDbf); Car := #0; {$I-} Reset(Dbf, 1); if not ErrorIO(FileDbf, IoResult) then begin Seek(Dbf, 28); {Flag’s […]

Database

Pack a Table

Pack a Table Packs a Paradox table by calling the BDE DbiDoRestructure function. The TTable passed as the first parameter must be closed. The TDatabase passed as the second parameter must be connected. function dgPackParadoxTable(Tbl: […]

Database

Select all Fields in a DBGrid

Select all Fields in a DBGrid function GridSelectAll(Grid: TDBGrid): Longint; begin Result := 0; Grid.SelectedRows.Clear; with Grid.DataSource.DataSet do begin First; DisableControls; try while not EOF do begin Grid.SelectedRows.CurrentRowSelected := True; Inc(Result); Next; end; finally EnableControls; […]