Solved

file protection

Posted on 2003-11-21
2
209 Views
Last Modified: 2010-05-01
Any experts can advice me on how to protect my exe file on a certain computer. I have written a program but I only want it to run on a certain PC only. If it is to be copied by an unauthorised personnel, the file should not run. Any ideas? Or is there a way i can prevent others from copying the file from my PC?

Colourblind82

0
Comment
Question by:colourblind82
2 Comments
 
LVL 24

Accepted Solution

by:
R_Rajesh earned 50 total points
ID: 9801915
Hi colourblind82,

Try tihs:

at the dos prompt type vol

C:\>vol
 Volume in drive C is Win2K2
 Volume Serial Number is 3F94-AE12

this will give you the volume serial of your c drive (will be different than the one listed here)

now in your vb program hard code it to a variable like cVol = 3F94AE12 (replace it with yours)

now in your startup form_load procedure you can compare this number with the serial of the current machine if they dont match then exit the program

---------
Public Declare Function GetVolumeSerialNumber Lib "kernel32" Alias _
"GetVolumeInformationA" (ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As Long, ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, ByVal lpMaximumComponentLength As Long, _
ByVal lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As Long, _
ByVal nFileSystemNameSize As Long) As Long

Public Function VolumeSerial(DriveLetter) As Long
Dim Serial As Long
Call GetVolumeSerialNumber(UCase(DriveLetter), _
0&, 0&, Serial, 0&, 0&, 0&, 0&)
VolumeSerial = Serial
End Function

Sub form_load()
cVol = "3F94AE12" 'replace this with the serial of your machine
If Hex(VolumeSerial("C:\")) <> cVol Then End
MsgBox "match"
End Sub
--------------------------

Cheers!

Raj
0
 

Author Comment

by:colourblind82
ID: 9807890
Thanks a lot

Colourblind82
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question