Registry de Run ve RunOnce

Yazdığınız makaleleri ve üyelerimizin işine yarayacağını düşündüğünüz kodlarınızı gönderebilirsiniz. Bu foruma soru sormayın!
Cevapla
Kullanıcı avatarı
gkimirti
Admin
Mesajlar: 1956
Kayıt: 02 Eyl 2003 04:44
Konum: İstanbul

Registry de Run ve RunOnce

Mesaj gönderen gkimirti »

Registry de bir programın her acılısta calısması yada bir kere calısması icin birisi guzel fonksiyonlar olusturmus
aynen buraya aktarıyorum
Kaynak:Torry.net

Kod: Tümünü seç

// Add the application to the registry...

procedure DoAppToRunOnce(RunName, AppName: string);
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  with Reg do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey('Software\Microsoft\Windows\CurrentVersion\RunOnce', True);
    WriteString(RunName, AppName);
    CloseKey;
    Free;
  end;
end;

Kod: Tümünü seç

// Check if the application is in the registry...

function IsAppInRunOnce(RunName: string): Boolean;
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  with Reg do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey('Software\Microsoft\Windows\CurrentVersion\RunOnce', False);
    Result := ValueExists(RunName);
    CloseKey;
    Free;
  end;
end;

Kod: Tümünü seç

// Remove the application from the registry...

procedure DelAppFromRunOnce(RunName: string);
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  with Reg do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey('Software\Microsoft\Windows\CurrentVersion\RunOnce', True);
    if ValueExists(RunName) then DeleteValue(RunName);
    CloseKey;
    Free;
  end;
end;

Kod: Tümünü seç

// Add the application to the registry...

procedure DoAppToRun(RunName, AppName: string);
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  with Reg do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', True);
    WriteString(RunName, AppName);
    CloseKey;
    Free;
  end;
end;

Kod: Tümünü seç

// Check if the application is in the registry...

function IsAppInRun(RunName: string): Boolean;
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  with Reg do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', False);
    Result := ValueExists(RunName);
    CloseKey;
    Free;
  end;
end;

Kod: Tümünü seç

// Remove the application from the registry...

procedure DelAppFromRun(RunName: string);
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  with Reg do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', True);
    if ValueExists(RunName) then DeleteValue(RunName);
    CloseKey;
    Free;
  end;
end;

Kod: Tümünü seç

// Examples

// Add app
DoAppToRun('Programm', 'C:\Programs\XYZ\Program.exe');

// Is app there ?
if IsAppInRun('Programm') then...

// Remove app,
DelAppFromRun('Programm'); 
Author: Ronald Rethfeldt (RoGaSoft)
Homepage: http://www.rogasoft.de
ÜŞENME,ERTELEME,VAZGEÇME
Kullanıcı avatarı
mussimsek
Admin
Mesajlar: 7603
Kayıt: 10 Haz 2003 12:26
Konum: İstanbul
İletişim:

Mesaj gönderen mussimsek »

Run ile RunOnce arasındaki fark şu. RunOnce'da yazdığınız program çalıştırılmadan önce kayıt silinir ve bir daha sorulmaz. Yani RunOnce'a yazdığınız program sadece 1 sefer çalışır.

Run kısmında ise her Windows başlangıcında çalışır.

Detay ve belge isterim diyene :) http://support.microsoft.com/default.as ... -US;137367

Kolay gelsin.
Cevapla