Results 1 to 4 of 4

Thread: [RESOLVED] [2008] Preventing form from loading unless specific file exists

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Resolved [RESOLVED] [2008] Preventing form from loading unless specific file exists

    How can I prevent my form from running unless a specific file is on
    the users pc? I need to make sure it's my software and not any exe
    with the same name? Perhaps a md5 hash check or something? So far
    this is all I have but want to have a better check or prevent the software
    from running.

    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         If My.Computer.FileSystem.FileExists("C:\Program Files\XYZ\xyz.exe") Then
    3.             Me.Show()
    4.         Else
    5.             MsgBox("You Need To Install XYZ To Continue")
    6.             Application.Exit()
    7.         End If
    8.     End Sub
    Last edited by cmmorris1; Oct 2nd, 2008 at 10:34 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2008] Preventing form from loading unless specific file exists

    Handle the Startup event of your application. NOTE: the application, NOT the form. You can then set e.Cancel to True to prevent the application running.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Re: [2008] Preventing form from loading unless specific file exists

    Thanks buddy, I was also looking for code that would do a file size check perhaps or what would be the best way for the program to check the file existence? an md5 hash check? I want the main form load event to check for the software and make sure it's not a phony .exe in the location posing as
    the real one? How can I be sure?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    Re: [2008] Preventing form from loading unless specific file exists

    Nevermind. Thanks jmcilhinney for your help, I think this is going to be ok. I think the other type of check is going overboard at this point.

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width