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] Reload Registry Settings...

Featured Replies

Posted

Hi Guys...

Hope someone can help me out with a problem in delphi programming.

First of all i'm coding in delphi since around 3 month.

I want to describe my prob a little bit more... I'm using windows 7 x64. In win7 and also in win vista you can add program links to the task bar. But you can only do this when the string "IsShortcut" is written in the windows registry. When this string exists you have on your desktop some "freeky" arrows on your links. So i made a little app to write and delete this string to the registry. For now so good. But you only see the changes take effect when you log off and on again. Or you do a complete system restart. And theres my problem. I know that its possible that windows reload this changes immediately without to be logged off and on again.

The simple code looks so...


procedure TForm1.Button1Click(Sender: TObject);
begin
RegAccess := TRegistry.Create(KEY_ALL_ACCESS);
try
RegAccess.RootKey := HKEY_LOCAL_MACHINE;
if RegAccess.OpenKey('SOFTWARE\Classes\lnkfile', True) then
RegAccess.WriteString('IsShortcut', ' ');
RegAccess.CloseKey;
if RegAccess.OpenKey('SOFTWARE\Classes\piffile', True) then
RegAccess.WriteString('IsShortcut', ' ');
RegAccess.CloseKey;
finally
RegAccess.Free;
Form2.Position := poMainFormCenter;
Form2.ShowModal;
end;
end;

I think the key to a solution is to use the "SendMessage" API with "WM_SettingChange". According to the MSDN Database the syntax is...

LRESULT WINAPI SendMessage( 
__in HWND hWnd,
__in UINT Msg,
__in WPARAM wParam,
__in LPARAM lParam );

So i implemented the function by this way...

SendMessage(HWND_Broadcast, WM_SettingChange, 0, 0);

To broadcast the "WM_SettingChange" message i got a tip from mazuki. Its needed to use the "SystemParametersInfo" function. I tested an implementation by this way...

SystemParametersInfo(SPI_SETICONS, 0, NULL, SPIF_SENDCHANGE);

But i still have no luck to get around this problem. Currently i have no idea what i could do more.

If its helpfull... I'm coding with Delphi 2010.

grEEtZ sILeNt heLLsCrEAm

Maybe running your tool "as Administrator" (<- use contextual menu to run it)?

Best regards

Nacho_dj

Delphi doesn't support 64 bit yet so your executable will only access the 32 bit side of the registry !

the settings you write won't be effective unless you run your application in a 32 bit OS

If you want windows to see the changed Registry settings, use C# or VB.NET and compile using AnyCPU settings

or use 64 bit of C++ compiler.

btw, 64 registry scanners use a driver to access the 32 bit side of the registry on Windows 64 so

it's not a new problem.

  • Author

No. I found a solution...

I implemented the "SHChangeNotify" function.

MSDN Syntax...

void SHChangeNotify(
LONG wEventId,
UINT uFlags,
__in_opt LPCVOID dwItem1,
__in_opt LPCVOID dwItem2
);
SHCNE_ASSOCCHANGED

A file type association has changed. SHCNF_IDLIST must be specified in the uFlags parameter. dwItem1 and dwItem2 are not used and must be NULL.

I implemented it like this...


Uses ShlObjSHChangeNotify(SHCNE_ASSOCCHANGED, 0, nil, nil);

And this is working... :yahoo:

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.