🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: GetVolumeInformation Problem

#10324
From: Ed Mulroy [TeamB]
Date: Sat, 24 Apr 2004 22:11
31 lines
2387 bytes
You are using IntToStr, a function which takes an int, a signed
number.  Automatic conversion between signed and unsigned integral
types is part of the language specification.  If the high bit is set
you then get a string representing a negative number, which is what
asked it to do.

There are several ways it could be done.
  AnsiString has a constructor which takes an unsigned long
  AnsiString's has a sprintf function
  Both sprintf and wsprintf will write to a character array that
    can then be assigned to an AnsiString

.  Ed

> LarryJ wrote in message
> news:408ae02c$1@newsgroups.borland.com...
>
> I am using the API GetVolumeInformation to see a customers
> hard drive serial number as seen below. I place the volume
> serial number into an unsigned long which has a maximum of
> 10 digits. 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. In addition, the
> Edit box some times shows a negative 10 digit number such
> as  "-1069816821" which the unsigned long theoretically can
> not even hold. Am I using the GetVolumeInformation wrong?
> Why are some people getting these bad results? I use hard
> drive serial number for registring my software so I need it to
> work.
Technical Details
Message-ID: <408ae5f7$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-mail
References: <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 15:38:49 PST
From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <408ae02c$1@newsgroups.borland.com>
Subject: Re: GetVolumeInformation Problem
Date: Sat, 24 Apr 2004 18:11:01 -0400
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 24.74.175.102
Message-ID: <408ae5f7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1082844663 24.74.175.102 (24 Apr 2004 15:11:03 -0700)
X-Authenticated-User: edmulroy
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