madhatter2002
Programmer
Does anybody know how to get the Hard disk serial number using VFP???
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
FUNCTION GetSerialNumber
LPARAMETERS pcDrive
DECLARE SHORT GetVolumeInformation IN kernel32;
STRING lpRootPathName,;
STRING @ lpVolumeNameBuffer,;
INTEGER nVolumeNameSize,;
INTEGER @ lpVolumeSerialNumber,;
INTEGER @ lpMaximumComponentLength,;
INTEGER @ lpFlags,;
STRING @ lpFileSystemNameBuffer,;
INTEGER nFileSystemNameSize
*!* BOOL GetVolumeInformation(
*!* LPCTSTR lpRootPathName, // root directory
*!* LPTSTR lpVolumeNameBuffer, // volume name buffer
*!* DWORD nVolumeNameSize, // length of name buffer
*!* LPDWORD lpVolumeSerialNumber, // volume serial number
*!* LPDWORD lpMaximumComponentLength, // maximum file name length
*!* LPDWORD lpFileSystemFlags, // file system options
*!* LPTSTR lpFileSystemNameBuffer, // file system name buffer
*!* DWORD nFileSystemNameSize // length of file system name buffer
*!* )
LOCAL lcDrive, lcVolName,lnSerialNum,lnComp,lnFlags,lcFileSystemName
lcDrive = iif(vartype(pcDrive)='C',pcDrive,Set('DEFAULT'))
do case
case len(lcDrive)=1
lcDrive = lcDrive + ':\'
case len(lcDrive)=2
lcDrive = lcDrive + '\'
endcase
lcVolName = space(100)
lnSerialNum = 0
lnComp = 0
lnFlags = 0
lcFileSystemName = space(100)
IF 0=GetVolumeInformation( lcDrive, @lcVolName, 100, ;
@lnSerialNum, @lnComp, @lnFlags, @lcFileSystemName, 100 )
lnSerialNum = 0xFFFFFFFF
endif
return lnSerialNum
ENDFUNC
Volume in drive C has no label.
Volume Serial Number is 3912-8833
Directory of C:
02/23/2000 09:48a <DIR> WINNT
02/23/2000 09:51a <DIR> Documents and Settings
Windows NT/2000 or later: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.