`
Par2: Hard drive serial number 1999-02-15 -- Ken Wagner Here's the code to get the Serial Number. The Hex conversion is included. Windows however ignores leading zero's in the 4 + 4 display of the volume serial number. You can see this if you use My Computer and then right click on the the drive icon and select disk information. I trust this gets you closer to your goal. See code below. Best regards for a flawless compile, PROGRAM !"After global includes" MAP COMPILE('***',_WIDTH32_) MODULE('WIN32.LIB') GetVolumeInformationA(*CSTRING,*CSTRING,LONG,*ULONG,*ULONG,*ULONG,*CSTRING,ULONG),BOOL,PASCAL,RAW END END *** LOC:RootPathName CSTRING(255) LOC:VolNameBuffer CSTRING(255) LOC:VolNameSize LONG LOC:VolSerialNr ULONG LOC:MaxFCL ULONG LOC:MaxFCF ULONG LOC:FileSystem CSTRING(255) LOC:FileSystemSize ULONG LOC:Entries ULONG LOC:SerialNo STRING(8) LOC:Result BYTE H LONG S BYTE N SHORT CODE LOC:RootPathName = 'C:\' LOC:VolNameSize = SIZE(LOC:VolNameBuffer) LOC:FileSystemSize = SIZE(LOC:FileSystem) CLEAR(LOC:VolSerialNr) X# = GetVolumeInformationA(LOC:RootPathName, | LOC:VolNameBuffer, | LOC:VolNameSize, | LOC:VolSerialNr, | LOC:MaxFCL, | LOC:MaxFCF, | LOC:FileSystem, | LOC:FileSystemSize) DO DecToHex MESSAGE('X#: ' & X# & '|' & | LOC:RootPathName & '|' & | LOC:VolNameBuffer & '|' & | LOC:VolNameSize & '|' & | LOC:SerialNo & '|' & | LOC:MaxFCL & '|' & | LOC:MaxFCF & '|' & | LOC:FileSystem & '|' & | LOC:FileSystemSize) DecToHex ROUTINE N = 1 LOOP H = (16 ^ N) IF H > LOC:VolSerialNr THEN BREAK. N += 1 END N -= 1 LOOP LOC:Result = INT(LOC:VolSerialNr / (16^N)) CASE LOC:Result OF 0 LOC:SerialNo[8-N] = '0' OF 1 LOC:SerialNo[8-N] = '1' OF 2 LOC:SerialNo[8-N] = '2' OF 3 LOC:SerialNo[8-N] = '3' OF 4 LOC:SerialNo[8-N] = '4' OF 5 LOC:SerialNo[8-N] = '5' OF 6 LOC:SerialNo[8-N] = '6' OF 7 LOC:SerialNo[8-N] = '7' OF 8 LOC:SerialNo[8-N] = '8' OF 9 LOC:SerialNo[8-N] = '9' OF 10 LOC:SerialNo[8-N] = 'A' OF 11 LOC:SerialNo[8-N] = 'B' OF 12 LOC:SerialNo[8-N] = 'C' OF 13 LOC:SerialNo[8-N] = 'D' OF 14 LOC:SerialNo[8-N] = 'E' OF 15 LOC:SerialNo[8-N] = 'F' END IF N < 0 THEN BREAK. IF N > 0 LOC:VolSerialNr = LOC:VolSerialNr - (LOC:Result*(16^N)) END N -= 1 END Printed November 23, 2024, 8:13 pm This article has been viewed/printed 35207 times. |