Registry.hpp 找不到
//UNIT1.H
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Registry.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TListBox *ListBox1;
TButton *Button1;
TButton *Button2;
TMemo *Memo1;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
//UNIT1.CPP
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h "
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm "
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TRegistry *Registry = new TRegistry;
try
{
ListBox1-> Items-> Clear();
Registry-> RootKey =HKEY_CURRENT_USER;
Registry-> OpenKey( "Software\\Microsoft\\Windows\\CurrentVersion\\Run ",false);
Registry-> GetValueNames(ListBox1-> Items);
Registry-> CloseKey();
}
__finally
{
delete Registry;
ListBox1-> ItemIndex=0;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TRegistry *Registry = new TRegistry;
AnsiString s;
if ( ListBox1-> Items-> Count )
{
Registry-> RootKey =HKEY_CURRENT_USER;
Registry-> OpenKey( "Software\\Microsoft\\Windows\\CurrentVersion\\Run ",false);
for (int i=0;i <ListBox1-> Items-> Count; i++)
{
s=Registry-> ReadString(ListBox1-> Items-> Strings[i]);
Memo1-> Lines-> Add( "键: "+ListBox1-> Items-> Strings[i]+ " 值: "+s);
}
Registry-> CloseKey();
}
delete Registry;
}
//---------------------------------------------------------------------------