Сделай сам: управление автозагрузкой | Программирование на Delphi и не только

Почитайте!

Нас читают

Статьи о программировании и не только

Mail.Ru

Rambler's Top100

Programming Blogs - BlogCatalog Blog Directory

Сделай сам: управление автозагрузкой

09.01.2008 от Иван Ширко

Страница: 1 2 3 4 5 6 7

reg := TRegistry.Create;
if PageControl1.ActivePageIndex<2 then
reg.RootKey := key
else
reg.RootKey:=windows.HKEY_LOCAL_MACHINE;
case PageControl1.ActivePageIndex of
0: reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', False);
1: reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\RunOnce', False);
2: reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\RunServices', False);
3: reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\RunServicesOnce', False);
end;
reg.WriteString(listview1.Items.Item[ActIndex].Caption,results);
reg.CloseKey;
reg.Free;
end
else
begin
AppIni:=TIniFile.Create('Win.INI');
path := appini.readstring('windows',listview1.Items.Item[ActIndex].Caption,'error');
temp := ListView1.Items.Item[actindex].SubItems.Strings[0];
i := pos(temp,path);
if i<>0 then
begin
delete(path, i, length(temp));
path := path + ' ' + results;
appini.writeString('windows',listview1.Items.Item[ActIndex].Caption, path);
AppIni.Free;
end;
end;
ListView1.Items.Item[actindex].SubItems.Strings[0] := Results;
end;
end;

Нажатие кнопки "Удалить":
procedure TForm1.ToolButton3Click(Sender: TObject);
var
temp: String;
begin
{если пользователь уверен в своём решении, то удаляем выбранный файл из автозагрузки}
if ListView1.ItemFocused.Selected then
if messagedlg('Вы уверены?', mtConfirmation, [mbYes,mbNo], 0) = mryes then
begin
ActIndex := ListView1.ItemFocused.Index;
if PageControl1.ActivePageIndex<4 then
begin
reg:=Tregistry.Create;
if PageControl1.ActivePageIndex<2 then reg.RootKey:=key
else
reg.RootKey:=windows.HKEY_LOCAL_MACHINE;
case PageControl1.ActivePageIndex of
0: reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', False);
1: reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\RunOnce', False);
2: reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\RunServices', False);
3: reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\RunServicesOnce', False);
end;
reg.DeleteValue(listview1.Items.Item[ActIndex].Caption);
reg.CloseKey;
reg.Free;
end else
begin
AppIni := TIniFile.Create('Win.INI');
path := AppIni.readstring('windows', listview1.Items.Item[ActIndex].Caption, 'error');
temp := ListView1.Items.Item[actindex].SubItems.Strings[0];
i := pos(temp,path);
if (i<>0) then
begin

Страница: 1 2 3 4 5 6 7

Рубрики: Delphi, Сделай сам |

Оставить комментарий

Заметьте: Включена проверка комментариев. Нет смысла повторно отправлять комментарий.