Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy protection
Message
From
18/10/2012 08:01:37
 
 
To
18/10/2012 07:58:00
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Installation, Setup and Configuration
Title:
Miscellaneous
Thread ID:
01555192
Message ID:
01555232
Views:
99
>>>We have been using a system based on the hard disk's serial number to stop the program from working on non-authorized computers; in Windows 7, this system fails miserably. It took me a while to figure this out, but it seems that this is on purpose: the Windows function that is supposed to return the hard disk's serial number fails, due to privacy concerns.
>>>
>>>Is there any way around this? For example, I might request administrative permissions for the program - although right now, I don't know how. Also, this verification would have to be done every time the program starts, and it would be quite a hassle for the user to authorize the program every time it starts.
>>>
>>>We have also considered getting the volume number instead - the information shown with the "vol" command in a DOS window. Once again, I am afraid this might fail if the user doesn't have administrative rights.
>>>
>>>The possibility of writing a random value to some obscure Registry key also occurred to me, but once again, I am not sure what sort of access rights this requires.
>>>
>>>Or how is this situation normally handled?
>>>
>>>TIA,
>>>
>>>Hilmar.
>>
>>What do you use to get the HDD serial number?
>
>There is a download here in the Universal Thread - a DLL that provides this information. It has worked in the past, but has started to fail miserable, in Windows 7. I assume you could also get the hard disk serial number with some function in the Windows API (and that they would fail just as miserably, for the same reason).

This works fine for me under all versions of Windows I have tested including Windows 7 32/64 and Windows 2008 32/64 and Windows 8 64. I have no idea anymore where i found this code - somewhere, maybe UT.
CLEAR

PUBLIC TARRAY
DECLARE TARRAY(10)

TARRAY = ""

=GETVOLINFO( "c:\", @TARRAY )

FOR I = 1 TO ALEN( TARRAY )
  ? TARRAY(I)
NEXT



Function GetVolInfo

Lparameters lcRoot, taInfo && Root of drive ie: "c:\", InfoArray passed by ref

Declare SHORT GetVolumeInformation IN Win32API;
  STRING @lpRootPathName, STRING @lpVolumeNameBuffer,;
  INTEGER nVolumeNameSize, integer @lpVolumeSerialNumber,;
  INTEGER @lpMaximumComponentLength, INTEGER @lpFileSystemFlags,;
  STRING @lpFileSystemNameBuffer, INTEGER nFileSystemNameSize

Store 0 TO lncomplen, lnsysflags, lnserialno
Store SPACE(260) TO lcvolname, lcsysname
Store LEN(lcvolname) TO lnvolsize, lnnamesize

If (GetVolumeInformation(@lcRoot, @lcvolname,;
    lnvolsize, @lnserialno, @lncomplen, @lnsysflags,;
    @lcsysname, lnnamesize) # 0)

  Dimension taInfo[3]

  taInfo[1] = substr(lcvolname, 1, at(chr(0),lcvolname)-1) && Volume name
  taInfo[2] = substr(lcsysname, 1, at(chr(0),lcsysname)-1) && Par.type
  taInfo[3] = trans(right(trans(iif(lnSerialNo < 0, ;
    0x7FFFFFFF-abs(lnSerialNo)+0x7FFFFFFF, lnSerialNo),'@0'),8) ) && Serial in hex format

Else

  taInfo = ""

Endif

Return
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Reply
Map
View

Click here to load this message in the networking platform