Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get Hard Drive information
Message
 
À
16/02/2005 14:39:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00987589
Message ID:
00987646
Vues:
63
If you are looking for a copy protection scheme...

Serial number is a form of MMNN-OOPP Where MM,NN,OO and PP are hex numbers. So it isn't really unique BUT you can read HD and other somehow constant values like WIN directory creation date, Nth hex code from NN.xxx file (among others) etc.

Then you can combine values with your own encryption key a unique KEY, which is save to f.ex. protect.dat file.

Every time when your app is launched HD serial number, WIN dir date etc... is red, encrypted key generated and compared to the encrypted value of protect.dat file.

Above of course needs that your APP has some kind of registration scheme. I.e. When APP is installed, metakey is generated which is then sent to you by your customer (or automaticly). Then you generate a propriate protec.dat (based on that unique metakey) which is then sent to your customer to release the APP from a trial period.
  Function cVolumeInfo(lpCDrive)

    If Type('m.lpCDrive') # 'C' Or At(':',m.lpCDrive) = 0
      m.lpCDrive = Sys(5)
    Endif

    m.lpCDrive = Addbs(m.lpCDrive)

    *******************************************************

    Local lpRootPathName, ;
      lpVolumeNameBuffer, ;
      nVolumeNameSize, ;
      lpVolumeSerialNumber, ;
      lpMaximumComponentLength, ;
      lpFileSystemFlags, ;
      lpFileSystemNameBuffer, ;
      nFileSystemNameSize

    Local retval, ;
      lcRetVal

    lpRootPathName           = m.lpCDrive && Drive and directory path
    lpVolumeNameBuffer       = Space(256) && lpVolumeName return buffer
    nVolumeNameSize          = 256        && Size of/lpVolumeNameBuffer
    lpVolumeSerialNumber     = 0          && lpVolumeSerialNumber buffer
    lpMaximumComponentLength = 256
    lpFileSystemFlags        = 0
    lpFileSystemNameBuffer   = Space(256)
    nFileSystemNameSize      = 256

    If Type('lVolInfoDeclared') = 'U'

      Declare Integer GetVolumeInformation In Win32API As GetVolInfo ;
        STRING  @lpRootPathName, ;
        STRING  @lpVolumeNameBuffer, ;
        INTEGER nVolumeNameSize, ;
        INTEGER @lpVolumeSerialNumber, ;
        INTEGER @lpMaximumComponentLength, ;
        INTEGER @lpFileSystemFlags, ;
        STRING  @lpFileSystemNameBuffer, ;
        INTEGER nFileSystemNameSize

    Endif

    m.retval=GetVolInfo(@lpRootPathName, @lpVolumeNameBuffer, ;
      nVolumeNameSize, @lpVolumeSerialNumber, ;
      @lpMaximumComponentLength, @lpFileSystemFlags, ;
      @lpFileSystemNameBuffer, nFileSystemNameSize)

    **---------------------------------------------------------------**
    ** Return code values for file system flags. Return codes are    **
    ** shown in parentheses. (m.retval return values)                **
    **---------------------------------------------------------------**
    ** FS_CASE_SENSITIVE     If this flag is set, the file system    **
    **                       supports case-sensitive file names      **
    **                       (0001h).                                **
    **                                                               **
    ** FS_CASE_IS_PRESERVED  If this flag is set, the file system    **
    **                       preserves the case of file names when   **
    **                       it places a name on disk (0002h).       **
    **                                                               **
    ** FS_UNICODE_ON_DISK    If this flag is set, the file system    **
    **                       supports Unicode in file names as they  **
    **                       appear on disk (0004h).                 **
    **                                                               **
    ** FS_PERSISTENT_ACLS    If this flag is set, the file system    **
    **                       preserves and enforces ACLs. For        **
    **                       example, NTFS preserves and enforces    **
    **                       ACLs, but HPFS and FAT do not (0008h)   **
    **                                                               **
    ** FS_FILE_COMPRESSION   The file system supports file-based     **
    **                       compression (0010h)                     **
    **                                                               **
    ** FS_VOL_IS_COMPRESSED  The specified volume is a compressed    **
    **                       volume; for example, a DoubleSpace      **
    **                       volume (8000h)                          **
    **---------------------------------------------------------------**
    ** The following information is pertinent to several of the      **
    ** listed flags:                                                 **
    **---------------------------------------------------------------**
    ** The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-**
    ** based compression. The file system name is not altered to     **
    ** indicate compression. This flag comes back set on a Double-   **
    ** Space volume, for example. With volume-based compression, an  **
    ** entire volume is either compressed or not compressed.         **
    **                                                               **
    ** The FS_FILE_COMPRESSION flag indicates whether a file system  **
    ** supports file-based compression. With file-based compression, **
    ** individual files can be compressed or not compressed.         **
    **                                                               **
    ** The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are    **
    ** mutually exclusive; both bits cannot come back set.           **
    **---------------------------------------------------------------**
    ** Note that the return value can be a combination of the        **
    ** individual return values. For example, a return value of 6    **
    ** indicates that case is preserved (FS_CASE_IS_PRESERVED) and   **
    ** the file system supports UNICODE in file names                **
    ** (FS_UNICODE_ON_DISK).                                         **
    **---------------------------------------------------------------**

    m.lcRetVal = m.lpVolumeSerialNumber

    Release lpRootPathName, ;
      lpVolumeNameBuffer, ;
      nVolumeNameSize, ;
      lpVolumeSerialNumber, ;
      lpMaximumComponentLength, ;
      lpFileSystemFlags, ;
      lpFileSystemNameBuffer, ;
      nFileSystemNameSize

    Clear DLLS "GetVolumeInformation"

    Return m.lcRetVal
Cheers,

AT
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform