Article View: borland.public.cppbuilder.nativeapi
Article #10328Re: GetVolumeInformation Problem
From: Remy Lebeau (TeamB)
Date: Sun, 25 Apr 2004 03:16
Date: Sun, 25 Apr 2004 03:16
37 lines
2151 bytes
2151 bytes
"LarryJ" <LarryJ33@ev1.net> wrote in message
news:408ae02c$1@newsgroups.borland.com...
> I convert the unsigned long into an AnsiString using IntToStr()
> and then show the number in an Edit box. The problem I am
> having is that the hard drive serial number sometimes show up
> in the edit box as a negative number which should not be
> possible using an unsigned long.
IntToStr() does not directly support unsigned values at all, so any unsigned
value will get implicitally converted to a signe values instead. As such,
any unsigned value above 2,147,483,647 will appear as negative.
Which version of BCB are you actually using? In BCB 5 and 6, IntToStr()
supports __int64 as well as int, so you can cast the unsigned value to
__int64 to order to prevent negative values. Otherwise, don't use
IntToStr() to begin with, but instead pass the unsigned value to the edit
box directly since AnsiString has always had a constructor that accepts
unsigned values.
> Why are some people getting these bad results?
Because you are misusing the value.
> CompNum = IntToStr(volser);
Change that to this instead:
CompNum = IntToStr((__int64)volser);
Or just:
CompNum = volser;
Gambit
Technical Details
Message-ID:
<408b2ef4$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<408ae02c$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c24bbdaaf95607e1 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-24 20:39:33 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <408ae02c$1@newsgroups.borland.com> Subject: Re: GetVolumeInformation Problem Date: Sat, 24 Apr 2004 20:16:19 -0700 Lines: 39 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.22.138.253 Message-ID: <408b2ef4$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1082863348 67.22.138.253 (24 Apr 2004 20:22:28 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail