|
|
Title | Prevent the user from renaming an executable in Visual Basic 6 |
Description | This example shows how to prevent the user from renaming an executable in Visual Basic 6. |
Keywords | rename, prevent rename, executable, execute |
Categories | Software Engineering, Miscellany |
|
|
When the program starts, it gets the current process's name. It compares that name to the program's original name stored in code. If the names do not match, the example program gives the original and new names. A real application might refuse to run.
|
|
Private Sub Form_Load()
Const CORRECT_NAME As String = "howto_dont_rename"
If LCase$(App.EXEName) = CORRECT_NAME Then
lblStatus.Caption = "Original name:" & _
vbCrLf & CORRECT_NAME
lblStatus.ForeColor = vbBlue
Else
lblStatus.Caption = "Renamed from:" & _
vbCrLf & CORRECT_NAME & vbCrLf & _
"To:" & vbCrLf & App.EXEName
lblStatus.ForeColor = vbRed
End If
End Sub
|
|
Note: To correctly find the name "howto_dont_rename" when running both in the IDE and in a compiled executable, the project name should be howto_dont_rename and the executable should be named howto_dont_rename.exe.
|
|
|
|
|
|