K
Kenny McCarty
I am trying to convert this snippet of c++ code to perl and am having
some problems getting the results to match up. I was hoping someone
might be able to help me out. Here is the snippet of C++ code:
DWORD dwVolSerial;
BOOL bIsRetrieved;
char *tmp;
char Data[6];
// Get the serial number
bIsRetrieved =
GetVolumeInformation("C:\\",NULL,NULL,&dwVolSerial,NULL,NULL,NULL,NULL);
// Display the serial number
printf("Serial number of drive C is %X\n",dwVolSerial);
tmp = (char*)&dwVolSerial;
Data[0] = tmp[0];
Data[1] = tmp[1];
Data[2] = tmp[2];
printf("Data is %d-%d-%d\n",Data[0],Data[1],Data[2]);
And here is what I tried in perl:
#just hard coded volume serial number here
$str = '303C-6B38';
@pieces = split(/-/,$str);
@data = split(//,$pieces[0]);
printf("Data: %d-%d-%d\n",ord($data[0]),ord($data[1]),ord($data[2]));
The C++ is run on Windows XP and the perl is run on Free-BSD. For the
perl part I want the user to input the volume serial number of their C
drive and I want to create a strign using this data. I think that the
conversions are different between windows and unix and that is where
my problem is but I am not sure. In windows the "3" becomes a "056"
but in unix it becomes a "53". Any help would be apprecieated.
Thanks.
some problems getting the results to match up. I was hoping someone
might be able to help me out. Here is the snippet of C++ code:
DWORD dwVolSerial;
BOOL bIsRetrieved;
char *tmp;
char Data[6];
// Get the serial number
bIsRetrieved =
GetVolumeInformation("C:\\",NULL,NULL,&dwVolSerial,NULL,NULL,NULL,NULL);
// Display the serial number
printf("Serial number of drive C is %X\n",dwVolSerial);
tmp = (char*)&dwVolSerial;
Data[0] = tmp[0];
Data[1] = tmp[1];
Data[2] = tmp[2];
printf("Data is %d-%d-%d\n",Data[0],Data[1],Data[2]);
And here is what I tried in perl:
#just hard coded volume serial number here
$str = '303C-6B38';
@pieces = split(/-/,$str);
@data = split(//,$pieces[0]);
printf("Data: %d-%d-%d\n",ord($data[0]),ord($data[1]),ord($data[2]));
The C++ is run on Windows XP and the perl is run on Free-BSD. For the
perl part I want the user to input the volume serial number of their C
drive and I want to create a strign using this data. I think that the
conversions are different between windows and unix and that is where
my problem is but I am not sure. In windows the "3" becomes a "056"
but in unix it becomes a "53". Any help would be apprecieated.
Thanks.