type THKEYTarget = (htLocalMachine, htCurrentUser); type TSectionTarget = (stRun, stRunOnce, stRunOnceEx); function StoreToRunSection(HKEYTarget: THKEYTarget; SectionTarget: TSectionTarget; Name, Data: string): boolean; var Reg: TRegistry; Section: string; begin Result := TRUE; try reg := TRegistry.Create; if HKEYTarget = htLocalMachine then reg.RootKey := HKEY_LOCAL_MACHINE; if HKEYTarget = htCurrentUser then reg.RootKey := HKEY_CURRENT_USER; if SectionTarget = stRun then Section := 'Run'; if SectionTarget = stRunOnce then Section := 'RunOnce'; if SectionTarget = stRunOnceEx then Section := 'RunOnceEx'; reg.LazyWrite := false; reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\' + Section, false); reg.WriteString(Name, Data); reg.CloseKey; reg.free; except RESULT := FALSE; end; end; // Пример использования: begin StoreToRunSection(htLocalMachine, stRun, 'Имя программы', application.exename); end;
|
Категория: Реестр и Делфи | Добавил: Admin (2006-12-17)
|
Просмотров: 1314
| Рейтинг: 0.0 |
|