Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Delphi] Snippets (Rev 0.1)

Featured Replies

Posted

I no longer use this routine, and if i were not to post it somewhere, it'll be a waste of code (why reinvent the wheel, right?) so i thought someone might find it useful or want to know how to use the Registry in Delphi..

procedure EnableBalloonTips(Enable: Boolean);
const
RegVal = 'EnableBalloonTips';
var
Reg: TRegistry;
begin
Reg := TRegistry.Create( KEY_WRITE or KEY_READ );
with Reg do
try
RootKey := HKEY_CURRENT_USER;
if OpenKey( 'Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\', True ) then
case Ord( Enable ) of
1:
begin
if ValueExists( RegVal ) then
DeleteValue( RegVal );
end;
0:
begin
if not ValueExists( RegVal ) then
WriteInteger( RegVal, Ord( False ) );
end;
end;
finally
CloseKey;
Free;
end;
end;
function UACEnabled: Boolean;
const
Val = 'EnableLUA';
var
Reg: TRegistry;
n : Integer;
begin
Result := False;
Reg := TRegistry.Create( KEY_READ );
with Reg do
try
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', False) then
if ValueExists(Val) then
begin
n := ReadInteger(Val);
case n of
0: Result := False;
1: Result := True;
end;
end;
finally
CloseKey;
Free;
end;
except
Exit;
end;
end;
Procedure DisableUAC;
Var
Reg: TRegistry;
Begin
Reg := TRegistry.Create( KEY_WRITE );
with Reg do
try
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', False) then
begin
WriteInteger('EnableLUA', 0);
WriteInteger('ConsentPromptBehaviorAdmin', 0);
WriteInteger('ConsentPromptBehaviorUser' , 0);
end;
finally
CloseKey;
Free;
end;
except
Exit;
end;
End;
Procedure SetRunAsAdminFlag(PathToExe: String);
Var
Reg: TRegistry;
Begin
Reg := TRegistry.Create( KEY_WRITE );
with Reg do
try
try
RootKey := HKEY_CURRENT_USER;
if OpenKey('Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', True) then
WriteString( PathToExe, 'RUNASADMIN' );
finally
CloseKey;
Free;
end;
except
Exit;
end;
End;
procedure AddRunOnce( ValueName, ExePath: String);
var
Reg: TRegistry;
begin
Reg := TRegistry.Create( KEY_WRITE );
with Reg do
try
RootKey := HKEY_LOCAL_MACHINE;
LazyWrite := False;
try
OpenKey( 'Software\Microsoft\Windows\CurrentVersion\RunOnce', True );
WriteString( ValueName, ExePath );
finally
CloseKey;
Free;
end;
except
Exit;
end;
end;

Edited by rotem156

  • Author

Updated..

Thanks , nice share

  • Author

btw, SetRunAsAdminFlag() doesn't run your App as admin directly, it just masks the flag in the Compatibility tab to your file...

do not get confused..

Edit: To mess with Windows Firewall, here's its Registry settings...

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\services\SharedAccess\Parameters\FirewallPolicy

Although, controling it via Com Objects is not hard also...

Edited by rotem156

  • 3 weeks later...

thanks,study delphi now

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.