Tag Archive: harddisk

Hard Disk Serial Number

> I need to read hard disk serial number from application written in Clarion
> 5.0 to protect application from unauthorized copying.

Anton Novikov:

Prototypes:
   GetVolumeInformationA(<*LPCSTR>,*LPSTR,DWORD,*DWORD,*DWORD,*DWORD,*LPSTR ,DWORD),BOOL,PASCAL,RAW
   GetLastError (),DWORD,PASCAL,NAME('GetLastError')

Parameters:
RootPathName         LPCSTR(4)
VolumeName           LPSTR(15)
VolumeNameSize       DWORD(128)
VolSerialNum         DWORD(15)                        !that's what you need
MaxCompLen           DWORD(15)
FileSysFlags         DWORD(15)
FileSysName          LPSTR(15)
FileSName            DWORD(15)

Code:
IF GetVolumeInformationA(, |
                           VolumeName, |
                           VolumeNameSize, |
                           VolSerialNum, |
                           MaxCompLen, |
                           FileSysFlags, |
                           FileSysName, |
                           FileSName)
        MESSAGE('VolumeName= ' & VolumeName & '|' & 'VolSerialNum= ' & VolSerialNum)
ELSE
        MESSAGE('API Error '& GetLastError())
END