[ActiveLock-Development] CVS: activelock2/src modComputerName.bas,NONE,1.1 modHDSerial.bas,NONE,1.1
Brought to you by:
ialkan
From: Dan <wiz...@us...> - 2003-07-29 22:16:16
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv10832/src Added Files: modComputerName.bas modHDSerial.bas modWindowsSerial.bas Log Message: Oops... Forgot to add the new files first! Added support for locks other than MAC. Hopefully a new test app will follow shortly. - Dan --- NEW FILE: modComputerName.bas --- Attribute VB_Name = "modComputerName" ' /////////////////////////////////////////////////////////////////////// ' / Filename: modComputerName.bas / ' / Version: 2.0.0.1 / ' / Purpose: Gets the name of the computer on the network. / ' / ActiveLock Software Group (ASG) / ' / / ' / Date Created: July 28, 2003 - Dan Sanders / ' / Date Last Modified: / ' / / ' / This software is released under the license detailed below and is / ' / subject to said license. Neither this header nor the licese below / ' / may be removed from this module. / ' /////////////////////////////////////////////////////////////////////// ' ' ' /////////////////////////////////////////////////////////////////////// ' / SOFTWARE LICENSE / ' /////////////////////////////////////////////////////////////////////// ' ' ActiveLock ' Copyright 1998-2002 Nelson Ferraz ' Copyright 2003 The ActiveLock Software Group (ASG) ' All material is the property of the contributing authors. ' ' Redistribution and use in source and binary forms, with or without ' modification, are permitted provided that the following conditions are ' met: ' ' [o] Redistributions of source code must retain the above copyright ' notice, this list of conditions and the following disclaimer. ' ' [o] Redistributions in binary form must reproduce the above ' copyright notice, this list of conditions and the following ' disclaimer in the documentation and/or other materials provided ' with the distribution. ' ' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ' A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ' OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ' LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ' DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ' THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ' OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ' ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// Private Declare Function ComputerName Lib "kernel32" Alias _ "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Const MAX_COMPUTERNAME_LENGTH = 15 Public Function GetComputerName() As String ' Stolen from ActiveLock 1.89. Author Unknown ' Returns: The name of the computer on the network Dim name As String, maxSize As Long, tmp As Long maxSize = MAX_COMPUTERNAME_LENGTH + 1 name = String(maxSize, 0) tmp = ComputerName(name, maxSize) GetComputerName = name End Function --- NEW FILE: modHDSerial.bas --- Attribute VB_Name = "modHDSerial" ' /////////////////////////////////////////////////////////////////////// ' / Filename: modHDSerial.bas / ' / Version: 2.0.0.1 / ' / Purpose: Gets the serial number of a specified harddrive. / ' / ActiveLock Software Group (ASG) / ' / / ' / Date Created: July 28, 2003 - Dan Sanders / ' / Date Last Modified: / ' / / ' / This software is released under the license detailed below and is / ' / subject to said license. Neither this header nor the licese below / ' / may be removed from this module. / ' /////////////////////////////////////////////////////////////////////// ' ' ' /////////////////////////////////////////////////////////////////////// ' / SOFTWARE LICENSE / ' /////////////////////////////////////////////////////////////////////// ' ' ActiveLock ' Copyright 1998-2002 Nelson Ferraz ' Copyright 2003 The ActiveLock Software Group (ASG) ' All material is the property of the contributing authors. ' ' Redistribution and use in source and binary forms, with or without ' modification, are permitted provided that the following conditions are ' met: ' ' [o] Redistributions of source code must retain the above copyright ' notice, this list of conditions and the following disclaimer. ' ' [o] Redistributions in binary form must reproduce the above ' copyright notice, this list of conditions and the following ' disclaimer in the documentation and/or other materials provided ' with the distribution. ' ' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ' A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ' OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ' LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ' DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ' THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ' OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ' ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// Public Declare Function apiGetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" _ (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _ lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, _ ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long Public Function GetHDSerial(strDriveLetter As String) As String ' Stolen from bjones - ActiveLock 1.89. ' ' Function to return the serial number for a hard drive ' Accepts: ' strDriveLetter - a valid drive letter for the PC, in the format "C:\" ' Returns: ' The serial number for the drive, formatted as "xxxx-xxxx" Dim lngReturn As Long, lngDummy1 As Long, lngDummy2 As Long, lngSerial As Long Dim strDummy1 As String, strDummy2 As String, strSerial As String strDummy1 = Space(260) strDummy2 = Space(260) lngReturn = apiGetVolumeInformation(strDriveLetter, strDummy1, Len(strDummy1), lngSerial, lngDummy1, lngDummy2, strDummy2, Len(strDummy2)) strSerial = Trim(Hex(lngSerial)) strSerial = String(8 - Len(strSerial), "0") & strSerial strSerial = Left(strSerial, 4) & "-" & Right(strSerial, 4) GetHDSerial = strSerial End Function --- NEW FILE: modWindowsSerial.bas --- Attribute VB_Name = "modWindowsSerial" ' /////////////////////////////////////////////////////////////////////// ' / Filename: modWindowsSerial.bas / ' / Version: 2.0.0.1 / ' / Purpose: Gets the serial number of a windows installation. / ' / Sounds like a good method for serial collecting to me! / ' / ActiveLock Software Group (ASG) / ' / / ' / Date Created: July 28, 2003 - Dan Sanders / ' / Date Last Modified: / ' / / ' / This software is released under the license detailed below and is / ' / subject to said license. Neither this header nor the licese below / ' / may be removed from this module. / ' /////////////////////////////////////////////////////////////////////// ' ' ' /////////////////////////////////////////////////////////////////////// ' / SOFTWARE LICENSE / ' /////////////////////////////////////////////////////////////////////// ' ' ActiveLock ' Copyright 1998-2002 Nelson Ferraz ' Copyright 2003 The ActiveLock Software Group (ASG) ' All material is the property of the contributing authors. ' ' Redistribution and use in source and binary forms, with or without ' modification, are permitted provided that the following conditions are ' met: ' ' [o] Redistributions of source code must retain the above copyright ' notice, this list of conditions and the following disclaimer. ' ' [o] Redistributions in binary form must reproduce the above ' copyright notice, this list of conditions and the following ' disclaimer in the documentation and/or other materials provided ' with the distribution. ' ' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ' A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ' OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ' LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ' DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ' THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ' OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ' ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// Public Function GetWindowsSerial() As String ' Stolen from bjones - ActiveLock 1.89. ' TODO: Add a beter method for detecting between Win95/98/Me vs NT/2K/XP ' The current implementation is very easy to fool. Not that it really matters. Dim strKey As String strKey = ReadRegVal(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", "ProductId", "") If strKey = "" Then strKey = ReadRegVal(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductId", "") End If GetWindowsSerial = strKey End Function |