This code demonstrates use of windows registery and function overloading to read from registery:
if key doesnt exist it's created and Default passed to key value ReadReg(KeyToRead,DefaultValue)
to write to registery:
writereg(KeyToWrite,ValueToKey)
Supports integer,string and boolean types, other type can be similary added.}

unit module1;

interface

uses Windows, registry;

function WriteReg(Key:string;value:integer) :boolean; overload;
function WriteReg(Key:string;value:boolean) :boolean; overload;
function WriteReg(Key:string;value:String) :boolean; overload;
function ReadReg(Key:string;default:String='') :string; overload;
function ReadReg(Key:string;default:integer=0) :integer; overload;
function ReadReg(Key:string;default:boolean=false):boolean;overload;

const
ApplicationName:string ='MyProgram'; //Your Programname

implementation

function ReadReg(Key:string;default:integer=0):integer;
var
Registry: TRegistry;
begin
Registry :=TRegistry.Create;
Registry.RootKey :=HKEY_CURRENT_USER;
Registry.OpenKey('\software\'+ ApplicationName,True);
if registry.ValueExists(key) =true then
result:=Registry.readinteger(key)
else
begin
Registry.Writeinteger(key,default);
result:=Registry.readinteger(key);
end;
Registry.Free;
end;

function ReadReg(Key:string;default:string=''):string;
var
Registry : TRegistry;
begin
Registry := TRegistry.Create;
Registry.RootKey :=HKEY_CURRENT_USER;
Registry.OpenKey('\software\'+ApplicationName,True);
if registry.ValueExists(key) then
readreg := Registry.readstring(key)
else
begin
Registry.Writestring(key,default);
Readreg := Registry.readstring(key);
end;
Registry.Free;
end;


function ReadReg(Key:string;default:boolean=false):boolean;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create;
Registry.RootKey := HKEY_CURRENT_USER;
Registry.OpenKey('\software\'+ApplicationName,True);
if registry.ValueExists(key) then
readreg:=Registry.readbool(key)
else
begin
Registry.Writebool(key,default);
readreg:=Registry.readbool(key);
end;
Registry.Free;
end;

function WriteReg(Key:string;value:boolean):boolean;
var Registry: TRegistry;
begin
Registry:=TRegistry.Create;
Registry.RootKey:=HKEY_CURRENT_USER;
Registry.OpenKey('\software\'+ApplicationName,True);
registry.WriteBool(key,value);
result:= registry.KeyExists(key);
Registry.Free;
end;

function WriteReg(Key:string;value:string):boolean;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create;
Registry.RootKey := HKEY_CURRENT_USER;
Registry.OpenKey('\software\'+ApplicationName,True);
registry.Writestring(key,value);
result:= registry.KeyExists(key);
Registry.Free;
end;

function WriteReg(Key:string;value:integer):boolean;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create;
Registry.RootKey := HKEY_CURRENT_USER;
Registry.OpenKey('\software\'+ApplicationName,True);
registry.Writeinteger(key,value);
writereg:= registry.KeyExists(key);
Registry.Free;
end;

Compare dates

Uses SysUtils;
...
if(Date < EncodeDate( 2000, 1, 1 )) then
Showmessage(' The date is ' + DateToStr(Date));

20 Responses so far.

  1. Anonymous says:

    This post came in a well-timed passion! I can't believe it. I'd been searching on the internet
    for Email Templates. You did an excellent job
    and yes i entirely agree that a template could make or break your internet business.
    Good Job!

    My web page: marketing email Templates

  2. Anonymous says:

    This article came in a well-timed ! I can't believe it. I was looking online for Email Templates. You did a fantastic job and yes i fully agree that a template could make or break your internet business. Best Wishes!

    Feel free to visit my web blog :: Email Announcement Templates

  3. Anonymous says:

    Excellent post. Keep posting such kind of information on your blog.
    Im really impressed by it.
    Hi there, You have done an excellent job. I'll definitely digg it and in my opinion suggest to my friends. I'm sure they'll be benefited from this site.

    Have a look at my web blog ... free email newsletter templates

  4. Anonymous says:

    Howdy this is somewhat of off topic but I was wanting to know
    if blogs use WYSIWYG editors or if you have to manually
    code with HTML. I'm starting a blog soon but have no coding experience so I wanted to get advice from someone with experience. Any help would be greatly appreciated!

    Also visit my webpage: email signature outlook 2010

  5. Anonymous says:

    Its like you read my mind! You seem to know so much about this, like you wrote the
    book in it or something. I think that you could do
    with a few pics to drive the message home a bit, but instead of that, this
    is magnificent blog. A great read. I'll certainly be back.

    my web page email announcement templates

  6. Anonymous says:

    Excellent way of explaining, and fastidious piece of writing to take data on the topic
    of my presentation topic, which i am going to present
    in school.

    My weblog; Email Templates Free

  7. Anonymous says:

    Great work! This is the kind of information that are
    meant to be shared across the internet. Shame on the search engines for now not positioning this
    submit upper! Come on over and consult with my site .
    Thanks =)

    my web page Outlook 2010 email Templates

  8. Anonymous says:

    It's remarkable to pay a quick visit this web page and reading the views of all friends concerning this piece of writing, while I am also keen of getting knowledge.

    my web page - business to business email marketing

  9. Anonymous says:

    Ahaa, its nice discussion about this article at this place at this blog, I have read all
    that, so now me also commenting at this place.

    Feel free to surf to my web page: arabic bridal makeup

  10. Anonymous says:

    I got this web site from my pal who informed me about this site and at the moment
    this time I am visiting this site and reading
    very informative content at this place.

    my blog http://www.truenuwaubu.com/my/Groups/evolve-your-email-templates-through-these-top-class-ideas/

  11. Anonymous says:

    Wonderful work! This is the type of info that should be shared across the
    web. Disgrace on Google for no longer positioning this submit higher!

    Come on over and visit my site . Thank you =)

    Here is my page :: Email Templates Gmail

  12. Anonymous says:

    I do not know if it's just me or if everyone else encountering issues with your website. It seems like some of the written text in your content are running off the screen. Can somebody else please provide feedback and let me know if this is happening to them too? This might be a problem with my browser because I've had this
    happen previously. Thanks

    Here is my web-site - Highly recommended Site

  13. Anonymous says:

    Good information. Lucky me I ran across your site by accident (stumbleupon).
    I've book marked it for later!

    Stop by my blog post: http://lightfoam.pera.com/author/BrittneyH []

  14. Anonymous says:

    wonderful publish, very informative. I wonder why the other experts of
    this sector do not understand this. You should proceed your writing.
    I am sure, you have a huge readers' base already!

    Feel free to visit my web site: html email templates

  15. Anonymous says:

    I pay a visit dаy-to-day sоme blogs anԁ informatiοn sіtеs to read posts,
    but this web site preѕents quality bаseԁ posts.


    My blog :: html email Templates

  16. Anonymous says:

    What's up, after reading this awesome article i am too glad to share my knowledge here with mates.

    my web-site - mouse click the next web page

  17. Anonymous says:

    Hello! I could have sworn I've been to this site before but after going through a few of the articles I realized it's new to me.

    Regardless, I'm definitely pleased I discovered it and I'll be bookmarking it and checking back often!



    Feel free to visit my site; free email marketing templates

  18. expertshelp says:

    The way you have written your content is great, very elaborate and in a professional manner. I am very sure that your intent was to communicate, and without a doubt you have done just that. Its with great satisfaction that i create this comment. Black Leather Office Desk Organizer Set Keep the spirit burning.

Post a Comment

Thank you for your comment.

Any request and idea are welcome.

CLICK TO REGISTER