|
-
Dec 19th, 2007, 02:13 AM
#1
Thread Starter
Hyperactive Member
USB Serial errors
basically i use a USB serial number security function where the user must have the USB drive inserted into their machine for my app to load.
on my machine this functions perfectly within a timley manner (couple of seconds) both in reporting an error if the drive is missing or moving on if its present. However on a users/clients machine if the USB is missing the app does not crash but takes it sweet time to report the USB missing, and ultimatley the user gets jack of waiting for it so they alt+ctl+del out of my app.
am i missing something, is this a bad idea for security?? or am i able to excluded particular drives from the serial number scan like A: and C: etc to save time..........................???
my code looks like this
Code:
If LicenseInfo.blnLoadNormal = True Then
txtValidationKey.Visible = True
Timer3.Enabled = False
Dim X As Integer
Dim Serial As Long
Dim VName As String
Dim FSName As String
Dim ret As Integer
For X = 0 To Drive1.ListCount - 1
Serial = 0
VName = String$(255, Chr$(0))
FSName = String$(255, Chr$(0))
GetVolumeInformation Drive1.List(X) & "\", VName, 255, Serial, 0, 0, FSName, 255
If Serial = CorrectSerial Then
GoTo CorrectDriveInserted
Else
If Serial = VDMasterSerial Then
GoTo CorrectDriveInserted
End If
End If
Next X
'Correct usb drive wasnt found, tell them, then exit the sub
ret = MsgBox("Please insert the correct Software Key and Restart the program", vbOKOnly, "Incorrect Software Key")
End
Else
Timer3.Enabled = False
Exit Sub
End If
CorrectDriveInserted:
LicenseInfo.strUSBDriveLetter = Drive1.List(X) 'this assigns the USB Key Drive letter to the Variable in mod LicenseInfo
CheckUpdate
cheers
Last edited by aztrix; Dec 19th, 2007 at 04:21 AM.
-
Dec 19th, 2007, 05:29 AM
#2
Re: USB Serial errors
am i able to excluded particular drives from the serial number scan like A: and C: etc to save time..........................???
yes you can get all the drives, then the type of the drive, you can then exclude fixed drive and cds
vb Code:
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: [url]http://www.allapi.net/[/url]
Dim strSave As String
'Set the graphic mode to persistent
Me.AutoRedraw = True
'Create a buffer to store all the drives
strSave = String(255, Chr$(0))
'Get all the drives
ret& = GetLogicalDriveStrings(255, strSave)
'Extract the drives from the buffer and print them on the form
For keer = 1 To 100
If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
Me.Print Left$(strSave, InStr(1, strSave, Chr$(0)) - 1)
strSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0)))
Next keer
End Sub
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: [url]http://www.allapi.net/[/url]
'Set the graphic mode to persistent
Me.AutoRedraw = True
'Get information about the C:\
Select Case GetDriveType("C:\")
Case 2
Me.Print "Removable"
Case 3
Me.Print "Drive Fixed"
Case Is = 4
Me.Print "Remote"
Case Is = 5
Me.Print "Cd-Rom"
Case Is = 6
Me.Print "Ram disk"
Case Else
Me.Print "Unrecognized"
End Select
End Sub
and exclude A: anyway
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 21st, 2007, 07:36 PM
#3
Thread Starter
Hyperactive Member
Re: USB Serial errors
cheers westconn1 ill give it a try, hopefully this will fasten it up on client machines.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|