如何操作注册表?(100分)

  • 主题发起人 主题发起人 nowgoo
  • 开始时间 开始时间
N

nowgoo

Unregistered / Unconfirmed
GUEST, unregistred user!
事情的经过是这样的:
偶女朋友有台电脑
她们寝室四个人一起用的
但她想把E盘留着自己用
问偶有没有给硬盘加密的方法
偶想了两个:
一、利用desktop.ini和folder.htt两个特殊文件,写一段密码验证的脚本来实现加密,
可是偶死活找不着相关资料,脚本写出来了,可就是用不上~:(
二、修改注册表来隐藏E盘。这个简单些,可是偶不知道怎么操作注册表,参考了一些
外国资料,可是看不太懂,其中有一句:
reg.WriteString('','')
格式是这样的,请问两个单引号各填什么数据?

如果能给出其它可行的方案,同样感谢!
 
who can help me?
 
可以通过TRegistry类方便地对注册表进行操作,在uses中增加Registry,例如:
procedure TForm1.FormCreate(Sender: TObject);
var Reg:TRegistry;
begin
Reg:= TRegistry.Create;
Reg.RootKey:= HKEY_CURRENT_USER;
if(Reg.OpenKey('/Software/例子',False))=False then
Reg.CreateKey('/Software/例子')
else
showmessage('!!!');
Reg.CloseKey;
Reg.Free;
end;
其它你最好参照下书籍,writestring是向一个键中写入某个具体数值,值为字符串类型,
还有writebool和writeinteger等等,不难懂。

如果是想防止硬盘中的数据被破坏的话,建议你装个'还原精灵'
 
The following example shows how to tell Windows to relaunch your application when Windows starts up if it was running when the system shut down. When Windows starts up, it launches each application listed in the RunOnce key and then deletes the entry for that application. Therefore, you do not need to remove the entry written here.

procedure TForm1.WMEndSession(var Message: TWMEndSession);
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/RunOnce',
True)
then Reg.WriteString('MyApp','"' + ParamStr(0) + '"');
finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
end;



In order for this method to be called, it must be declared in the interface section of your unit as follows:

private

procedure WMEndSession(var Msg:TWMEndSession); message
WM_ENDSESSION;



13. 读写注册表的二进制值
uses .., registry;

procedure TForm1.Button2Click(Sender: TObject);
var
Reg: TRegistry;
b,b2:array[0..10] of char;
i,n:integer;
begin
Reg := TRegistry.Create;
b[0]:=#10; //10
b[1]:='1'; //49
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/RunOnce', True)
then
begin
Reg.WriteBinaryData('MyApp',b,2);
n:=Reg.ReadBinaryData('MyApp',b2,10);
showmessage(inttostr(n));
for i:=0 to n-1 do showmessage(inttostr(integer(b2)));
end;

finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
end;
 
不好意思,我只有一百块了
很想给各位一人一百啊!
实在太感谢了!!!!!!!!
恩人哪~
 
注册表不是有三种数据么?
文本,二进制,还有DWORD
要写一个DWORD怎么办呀?
 
修改如下:
procedure TForm1.FormCreate(Sender: TObject);
var
reg:Tregistry;
a:array[0..10] of char;
begin
reg:= Tregistry.Create;
reg.RootKey:= HKEY_CURRENT_USER;
if(reg.OpenKey('/Software/例子',False))=False then
begin
reg.CreateKey('/Software/例子');
reg.OpenKey('/Software/例子',true);
reg.WriteString('string','字符串');
reg.WriteInteger('dword',5);//就是数值吧?弄不清楚,我很笨。
a[0]:='a';
reg.WriteBinaryData('二进制',a,1);
end
else
showmessage('!!!');
Reg.CloseKey;
Reg.Free;
end;
 
呵呵,jsxjd粘的就很详细了,OK,给分?[:D]
 
后退
顶部