delphi怎样可以读取注册表中的信息,进行注册表操作??我做的delphi程序应该算是绿色的吧,不需要写注册表就可以了,但是要求制作成为不安装不能够使用的形式,怎么办?大家多多提高见,谢谢~
解决方案 »
- 周末了,散点分,祝大家周末愉快!
- 急聘:Delphi软件工程师。
- property OnDragOver stored IsForm;这里的stored IsForm是什么意思?
- DBGridEh 高手帮忙啊:DBGridEh 设置某列的下拉列表。
- delphi能作什么?
- 高手解读.
- 有谁知道vc中的定义怎样在delphi中实现,高分求助
- ODAC访问ORACLE数据库问题
- 有两张相同的表,怎样用SQL语句将第一张表的某一行记录拷贝到另一张表中
- 请你指点------一个delphi新手
- 小问Dephi中的一个简单问题,欢迎大家指点!^_^
- 求助:用Delphi在指定图片上插入汉字,怎样实现??
function Read_Registry : string ;
const SECTION = 'Wp';
var FIniFile: TRegIniFile;
begin
FIniFile := TRegIniFile.Create('Software');
Result := FIniFile.ReadString(SECTION, 'ResInOut', '');
end;
该函数读取是
HKEY_CURRENT_USER\software\wp\
下'ResInOut'的值
unit regApp; interface uses Windows,SysUtils,Registry,forms, Dialogs; type
Tlogin = class
private
public
constructor Create; virtual;
procedure CheckLogin;
end;
implementation constructor Tlogin.Create;
begin
inherited Create;
end; procedure Tlogin.CheckLogin;
var
Reg_id: TDateTime;
RegisterTemp: TRegistry;
InputStr, Get_id: string;
Reg_tag, ClickDok: Boolean;
Allow: Integer;
begin
Allow := 30; //试用期为30天
Reg_tag := False; //软件是否到注册期
registerTemp := TRegistry.Create; //准备使用注册表
with registerTemp do
begin
RootKey := HKEY_LOCAL_MACHINE; //存放
if OpenKey(''Software\Microsoft\Windows\CurrentSowft\tag'', True) then // 建一目录,存放标志值
begin
if ValueExists(''DateTag'') then begin //用DateTag的值作为标志
Reg_id := ReadDate(''DateTag''); //读出标志值
if (Reg_id <> 0) and (Now - Reg_id > Allow) then //允许使用的时间到
Reg_tag := True;
end
else
WriteDateTime(''DateTag'', Now); //建立标志,并置初始标志值。
end;
if Reg_tag then begin //要求用户输入注册码
ClickDok := InputQuery(''您使用的是非注册软件,请输入注册码:'', '' '', inputstr);
if ClickDok then begin
Get_id := IntToStr(2222); //注册码2
if Get_id = InputStr then begin
WriteDateTime(''DateTag'', 0); //将标志值置为0,即已注册。
CloseKey;
Free;
end
else begin //若输入的注册码错误
Application.MessageBox(''注册码错误!请与作者联系!'', ''警告框'', mb_ok);
CloseKey;
Free;
Application.Terminate;
end;
end
else begin //若用户不输入注册码
Application.MessageBox(''请与作者联系,使用注册软件!'', ''警告框'', mb_ok);
CloseKey;
Free;
Application.Terminate;
end;
end;
end;
end; end.
function GetRegistryValue: string;
var
Registry: TRegistry;
S: string;
begin
Registry:=TRegistry.Create; Registry.RootKey:=HKEY_LOCAL_MACHINE;
{False because we do not want to create it if it doesn抰 exist}
Registry.OpenKey('MYKEY',False);
Result :=Registry.ReadString('VALUE1'); Registry.Free;
end;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
begin
Reg.WriteString('MyApp','"' + ParamStr(0) + '"');
Reg.CloseKey;
end;
finally
Reg.Free;
inherited;
end;end;
In order for this method to be called, it must be declared in your main form class as follows:private procedure WMEndSession(var Msg:TWMEndSession); message WM_ENDSESSION;