Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Volume information 2

Status
Not open for further replies.

jmnagi

Programmer
Oct 17, 2002
47
0
0
GB
hi.

i heard not all hard disks have serial numbers. is that really true ? i heard SCSI ones {most of them} don't have serial numbers.

anyway, if i use "GetVolumeInformation()" how unique can i expect the volume serial number to be?

i need to get some information from the computer that is fairly unique and in HEX values. please help

br: nagi

--
br: nagi
 
How about the MAC-address of the network card - it should be unique.

/JOlesen
 
I stole this code somewhere out of MSDN library to obtain the mac address. It is C, not C++, but for me it works. Link it with netapi32.lib.

Code:
#include <windows.h>
#include <wincon.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

typedef struct _ASTAT_
{ ADAPTER_STATUS adapt;
  NAME_BUFFER    NameBuff [30];
} ASTAT, * PASTAT;

ASTAT Adapter;

void main (void)
{
  NCB Ncb;
  UCHAR uRetCode;
  char NetName[50];
  LANA_ENUM   lenum;
  int      i;

  memset( &Ncb, 0, sizeof(Ncb) );
  Ncb.ncb_command = NCBENUM;
  Ncb.ncb_buffer = (UCHAR *)&lenum;
  Ncb.ncb_length = sizeof(lenum);
  uRetCode = Netbios( &Ncb );
  printf( &quot;The NCBENUM return code is: 0x%x \n&quot;, uRetCode );

  for (i=0; i < lenum.length ;i++)
     { memset( &Ncb, 0, sizeof(Ncb) );
       Ncb.ncb_command = NCBRESET;
       Ncb.ncb_lana_num = lenum.lana[i];

       uRetCode = Netbios( &Ncb );
       printf( &quot;The NCBRESET on LANA %d return code is: 0x%x \n&quot;,
               lenum.lana[i], uRetCode );

       memset( &Ncb, 0, sizeof (Ncb) );
       Ncb.ncb_command = NCBASTAT;
       Ncb.ncb_lana_num = lenum.lana[i];

       strcpy( Ncb.ncb_callname,  &quot;*               &quot; );
       Ncb.ncb_buffer = (char *) &Adapter;
       Ncb.ncb_length = sizeof(Adapter);

       uRetCode = Netbios( &Ncb );
       printf( &quot;The NCBASTAT on LANA %d return code is: 0x%x \n&quot;,
               lenum.lana[i], uRetCode );
       if ( uRetCode == 0 )
          { printf ( &quot;The Ethernet Number on LANA %d is: %02x%02x%02x%02x%02x%02x\n&quot;,
                     lenum.lana[i],
                     Adapter.adapt.adapter_address[0],
                     Adapter.adapt.adapter_address[1],
                     Adapter.adapt.adapter_address[2],
                     Adapter.adapt.adapter_address[3],
                     Adapter.adapt.adapter_address[4],
                     Adapter.adapt.adapter_address[5] );  } } }


Marcel
 
With the network MAC address solutions ... what if they don't have a network card?

I have used the HD serial number to create a unique identifier for computers to prevent users from stealing software licenses. This method has worked for me to date. I don't know if my software has ever been installed on a SCSI harddrive or not?

I would be interested in learning if there are other hardware codes that can be retrieved for this type of use. I know the MS has used hardware codes to protect its software, so I assume that there are other hardware codes that are available.

Hope this helps.
 
FWIW: Any information can be represented in Hex values: It's just another numbering base, like a number using 0 & 1 is in binary (base 2), 0123456789 is base 10, 0123456789ABCDEF is in hex (base 16).

Normal strings use the whole ascii table, minus chr(0) (if it's used as a terminator), and so could be called &quot;base 255&quot; (or base 256 if a length is used instead of a chr(0) terminator).

So, you can convert any information into a hexadecimal number represented in a base 255 ascii string using the 0-9,A-F characters.
 
hi ..

JOLSEN: i read from an IEEE journal that MAC address can be spoofed. so, i think MAC is not really a useful information in this regard. {i do understand that if anyone plays around with their MAC there are a lot of things that could go wrong}.

WGCS: for example, if i have a string xA12-y3CF-8JgV-BHG2 you mean to say i can convert this to hexadecimal ?


--
br: nagi
 
You can convert a string to hex by using the ascii values for each character. The ascii character set is used by the computer to represent each character by a number. This number can be in any base you want. Decimal is base 10, Binary base 2, and Hex is base 16. In fact the binary ascii representation is how characters are stored to disk and how they are represented in memory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top