[ActiveLock-Development] CVS: activelock2/src ActiveLock.cls,1.8,1.9 ActiveLock2.dll,1.4,1.5 ActiveL
Brought to you by:
ialkan
From: Dan <wiz...@us...> - 2003-07-31 15:53:54
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv13564/src Modified Files: ActiveLock.cls ActiveLock2.dll ActiveLock2.vbp modHDSerial.bas Log Message: Added support for network drives to GetHDSerial(). If it fails, it tries the drive in %WINDIR%, and if that fails, it tries C:. If that fails, 0000-0000 is returned. - Dan Index: ActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock.cls,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ActiveLock.cls 31 Jul 2003 07:04:53 -0000 1.8 +++ ActiveLock.cls 31 Jul 2003 15:49:54 -0000 1.9 @@ -296,7 +296,7 @@ strLock = strLock & modComputerName.GetComputerName() End If If mLockTypes And lockHD Then - strLock = strLock & modHDSerial.GetHDSerial("C:\") + strLock = strLock & modHDSerial.GetHDSerial() End If If mLockTypes And lockWindows Then strLock = strLock & modWindowsSerial.GetWindowsSerial() Index: ActiveLock2.dll =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock2.dll,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 Binary files /tmp/cvsrPVx5b and /tmp/cvsK57XHe differ Index: ActiveLock2.vbp =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock2.vbp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ActiveLock2.vbp 29 Jul 2003 18:49:42 -0000 1.8 +++ ActiveLock2.vbp 31 Jul 2003 15:49:54 -0000 1.9 @@ -1,5 +1,5 @@ Type=OleDll -Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\WINNT\System32\stdole2.tlb#OLE Automation +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\system32\STDOLE2.TLB#OLE Automation Class=ActiveLock; ActiveLock.cls Class=IActiveLock; IActiveLock.cls Class=Globals; Globals.cls Index: modHDSerial.bas =================================================================== RCS file: /cvsroot/activelock/activelock2/src/modHDSerial.bas,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- modHDSerial.bas 29 Jul 2003 18:58:16 -0000 1.1 +++ modHDSerial.bas 31 Jul 2003 15:49:54 -0000 1.2 @@ -6,7 +6,7 @@ ' / ActiveLock Software Group (ASG) / ' / / ' / Date Created: July 28, 2003 - Dan Sanders / -' / Date Last Modified: / +' / Date Last Modified: July 30, 2003 - Dan Sanders / ' / / ' / This software is released under the license detailed below and is / ' / subject to said license. Neither this header nor the licese below / @@ -47,11 +47,19 @@ ' (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 TO DO LIST / +' /////////////////////////////////////////////////////////////////////// +' +' [ ] Decide what to to about shared folders and RAID arrays +' ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// ' +' 07.30.03 - wizzardme2000 - Added support for network shares +' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// @@ -61,23 +69,87 @@ 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. +Declare Function GeneralWinDirApi Lib "kernel32" _ + Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _ + ByVal nSize As Long) As Long + +Private Function HDSerial(path As String) As String +'TODO: Decide what to to about shared folders and RAID arrays ' ' Function to return the serial number for a hard drive -' Accepts: -' strDriveLetter - a valid drive letter for the PC, in the format "C:\" +' Currently works on local drives, mapped drives, and shared drives. +' ' Returns: -' The serial number for the drive, formatted as "xxxx-xxxx" +' The serial number for the drive alock is on, 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 + Dim strDriveLetter As String, lngFirstSlash As Long + + strDriveLetter = path + + '(Just in case... It's better to be safe than sorry.) + strDriveLetter = Replace(strDriveLetter, "/", "\") + + 'Check the drive type + If Not Left(strDriveLetter, 1) = "\" Then + 'Good... The path is a local drive + strDriveLetter = Left(strDriveLetter, 3) + Else + 'It's a network drive + 'This will return 0000-0000 on shared folders or RAID arrays + 'Shared drives work fine + lngFirstSlash = InStr(3, strDriveLetter, "\") + strDriveLetter = Left(strDriveLetter, lngFirstSlash) + End If + + 'Set up dimmies strDummy1 = Space(260) strDummy2 = Space(260) + + 'Call the API function lngReturn = apiGetVolumeInformation(strDriveLetter, strDummy1, Len(strDummy1), lngSerial, lngDummy1, lngDummy2, strDummy2, Len(strDummy2)) + + 'Format the serial strSerial = Trim(Hex(lngSerial)) strSerial = String(8 - Len(strSerial), "0") & strSerial strSerial = Left(strSerial, 4) & "-" & Right(strSerial, 4) + HDSerial = strSerial +End Function + +Function GetHDSerial() As String +' Function to return the serial number for a hard drive +' Currently works on local drives, mapped drives, and shared drives. +' Checks windir if it cant get a serial, then c:, then returns 0000-0000 +' +' Returns: +' The serial number for the drive alock is on, formatted as "xxxx-xxxx" +' +' I think that this is 99.999999897456284893% effective. + + Dim strSerial + strSerial = HDSerial(App.path) + + If strSerial = "0000-0000" Then + 'Calculate WINDIR drive if couldn't retrieve app.path serial + strSerial = HDSerial(WinDir()) + End If + + If strSerial = "0000-0000" Then + 'If it still can't get a serial, revert to c:. + 'If no c: is present (or c: is RAID), 0000-0000 is returned + strSerial = HDSerial("C:\") + End If + GetHDSerial = strSerial +End Function + +Private Function WinDir() As String + Const FIX_LENGTH% = 4096 + Dim Length As Integer + Dim Buffer As String * FIX_LENGTH + + Length = GeneralWinDirApi(Buffer, FIX_LENGTH - 1) + WinDir = Left$(Buffer, Length) End Function |