🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12228

Re: FirstTimeWindowsInstalled.

#12228
From: Remy Lebeau (TeamB)
Date: Wed, 17 Dec 2003 00:43
63 lines
3073 bytes
"Safari" <Safari@alloymail.com> wrote in message
news:3fdf87d6@newsgroups.borland.com...

>          // --------------------------------- Error!
>          // Return me: 30314/21/01!

That is because you did not interpret the returned value at all, you tried
to use it as-is.  Under Win9x/Me, you are calling FileDateToDateTime() to
convert the value into something meaningful.  You need to do the same thing
under NT/2K/XP as well.  But you are not actually doing so.

With that said, I would also suggest that you try using the following code
(untested):

    type
        TIntegerBytes = packed record
            case Integer Of
                0: (
                    Bytes: Array[0..3] of Byte);
                1: (
                    Value: LongInt);
        end;
    var
        TIntegerBytes: InstallDate;
        Regis: TRegistry;
        KeyName: ValueName: String;
    begin
        case Win32Platform of
            VER_PLATFORM_WIN32_WINDOWS:
            begin
                KeyName := '\Software\Microsoft\Windows\CurrentVersion';
                ValueName := 'FirstInstallDateTime';
            end;
            VER_PLATFORM_WIN32_NT:
            begin
                KeyName := '\Software\Microsoft\Windows NT\CurrentVersion';
                ValueName := 'InstallDate';
            end;
        end;

        Regis := TRegistry.Create;
        Regis.RootKey := HKEY_LOCAL_MACHINE;
        try
            if Regis.OpenKeyReadOnly(KeyName) then
            begin
                // the value can be stoed in either binary or DWORD format
                if (Regis.GetDateType(ValueName) = rdBinary) then
                    Regis.ReadBinaryData(ValueName, InstallDate.Bytes,
SizeOf(InstallDate.Bytes))
                else
                    InstallDate.Value := Regis.ReadInteger(ValueName);
                Regis.CloseKey;
                Label1.Caption := FormatDateTime('yyyy/mm/dd',
FileDateToDateTime(InstallDate.Value));
            end;
        finally
            Regis.Free;
        end;
    end;


Gambit
Technical Details
Message-ID: <3fdfa595$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fdc4d66@newsgroups.borland.com> <3fdcddd4$1@newsgroups.borland.com> <3fdf87d6@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,4bc4a0b3c60109c0
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-16 16:39:51 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3fdc4d66@newsgroups.borland.com> <3fdcddd4$1@newsgroups.borland.com> <3fdf87d6@newsgroups.borland.com>
Subject: Re: FirstTimeWindowsInstalled.
Date: Tue, 16 Dec 2003 16:43:33 -0800
Lines: 65
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.23.78.224
Message-ID: <3fdfa595$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1071621525 67.23.78.224 (16 Dec 2003 16:38:45 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail