Article View: borland.public.delphi.nativeapi
Article #3Re: Retreive Hardware Info: Processor ID, HD ID, etc?
From: Rodolfo Frino - Macrosoft
Date: Fri, 19 Dec 2003 06:10
Date: Fri, 19 Dec 2003 06:10
110 lines
4343 bytes
4343 bytes
For the HD
#pragma pack(push, 1)
struct TDiskInfo
{
DWORD Serial;
__int64 dvSize;
__int64 dvFree;
__int64 dvUsed;
char Select[16];
char Volume[256];
char System[256];
};
#pragma pack(pop)
TDiskInfo __fastcall GetDiskInfo(AnsiString Value)
{
WORD ErrMode;
DWORD Words, Flags;
TDiskInfo R = {0};
ErrMode = (WORD)SetErrorMode(SEM_FAILCRITICALERRORS); //win32 API
try
{
switch(GetDriveType(Value.c_str()))
{
case DRIVE_NO_ROOT_DIR:
StrLCopy(R.Select, "Drive Does not exist", 16);
break;
case DRIVE_UNKNOWN:
StrLCopy(R.Select, "Drive is unknown", 16);
break;
case DRIVE_FIXED:
StrLCopy(R.Select, "Fixed Drive", 16);
break;
case DRIVE_REMOVABLE:
StrLCopy(R.Select, "Removable Drive", 16);
break;
case DRIVE_REMOTE:
StrLCopy(R.Select, "Remote Drive", 16);
break;
case DRIVE_CDROM:
StrLCopy(R.Select, "CDROM Drive", 16);
break;
case DRIVE_RAMDISK:
StrLCopy(R.Select, "RAM Disk Drive", 16);
break;
}
R.dvSize = DiskSize(0);
R.dvFree = DiskFree(0);
R.dvUsed = (R.dvSize - R.dvFree);
GetVolumeInformation(Value.c_str(), R.Volume,
sizeof(R.Volume), &R.Serial, &Words, &Flags, R.System,
sizeof(R.System));
}
__finally {
SetErrorMode(ErrMode);
}
return R;
}
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TDiskInfo D;
Disks = GetDiskInfo("C:\\");
ShowMessage(String(D.Volume) + "\n" +
String(D.System) + "\n" +
String(D.Select) + "\n" +
"Serial No " + String(D.Serial) + "\n" +
"Disk Size " + String(D.dvSize) + " MB\n" +
"Free Space " + String(D.dvFree) + " MB\n" +
"Used Space " + String(D.dvUsed) + " MB"
);
}
Rodolfo
"Muzzy" <leyandrew@yahoo.com> wrote in message
news:3fe1f4f1$1@newsgroups.borland.com...
> Hello,
>
> I need to implement sort of subscription service for my app and for that
> purpose i need to generate a unique code (computer ID) sequence for
> particular computer.
>
> I would like to generate the code based on processor ID and probably
> some other hardware id's, just like microsoft does for WinXP registration.
>
> But i don't seem to find any WinAPI(?) functions to retreive that info.
>
> Any ideas would be highly appreciated!
>
> Thank you,
> Andrey
>
Technical Details
Message-ID:
<3fe29623@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fe1f4f1$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,8575db85be168bd6 X-Google-Attributes: gid10cc67,public X-Google-Thread: f94dd,8575db85be168bd6 X-Google-Attributes: gidf94dd,public X-Google-ArrivalTime: 2003-12-18 22:10:08 PST From: "Rodolfo Frino - Macrosoft" <Macrosoft@Atlantis.com> Newsgroups: borland.public.delphi.nativeapi,borland.public.cppbuilder.nativeapi References: <3fe1f4f1$1@newsgroups.borland.com> Subject: Re: Retreive Hardware Info: Processor ID, HD ID, etc? Date: Fri, 19 Dec 2003 17:10:00 +1100 Lines: 112 Organization: Macrosoft Corporation 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: 203.206.21.87 Message-ID: <3fe29623@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071814179 203.206.21.87 (18 Dec 2003 22:09:39 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail