Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to take effect immedietaly after modify registry or group policy?

57 views
Skip to first unread message

M$

unread,
Jan 18, 2005, 12:50:40 AM1/18/05
to

I had try the following code ,but no effect:

/// Example: I wan't show RUN item on start menu ,so modify the registry,
and don't want restart computer to take effect!
function RefreshPolicyEx(Machine: Boolean; aType: DWORD): Boolean; stdcall;
external 'userenv.dll';

function RegWriteInteger(const RootKey: HKEY; const SubKey, ValueName:
string; const Value: integer): Boolean;
var
Key: HKEY;
R: DWORD;
begin
Result := (ERROR_SUCCESS = RegCreateKeyEx(RootKey, PChar(SubKey), 0,
'Data',
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nil, Key, @R)) and
(ERROR_SUCCESS = RegSetValueEx(Key, PChar(ValueName), 0, REG_DWORD,
@Value, SizeOf(Value)));
RegCloseKey(Key);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
RegWriteInteger(HKEY_CURRENT_USER,
'Software\Microsoft\Windows\CurrentVersion\Policies\Explorer',
'NoRun', SpinEdit1.Value);

//SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
integer(Pchar('Explorer')));
if RefreshPolicyEx(False, 1) then Caption := 'OK' else Caption := 'Error';
end;

accoding MSDN, i use gpupdate command line tools, but also no effect.

how about this?
Thanks in advance.


xtreme...@gmail.com

unread,
Mar 13, 2016, 3:44:27 AM3/13/16
to
Gurr ir Hur Hur Grir
0 new messages