Results 1 to 7 of 7

Thread: Assign Embedded exe to button

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Exclamation Assign Embedded exe to button

    after all the resources are added to the project , is there a way to write everything on startup to a temp folder and assign exes to buttons ?

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Assign Embedded exe to button

    I'm sure I have seen another thread like this..

    O yes, its yours! Link

  3. #3
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Re: Assign Embedded exe to button

    First step is adding the executable in your project resources. (My project-Resources-Add Resource\/ - Add existing file)

    Once this executable is visible in the "Project Properties" tab, you can use it.

    You can't simply execute an executable which is in memory, so you'll have to write it to a file first:
    Code:
        Private beeperfile As String
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            beeperfile = My.Computer.FileSystem.SpecialDirectories.Temp & "\beeper.exe"
            Dim writer As New IO.FileStream(beeperfile, IO.FileMode.Create, IO.FileAccess.Write)
            writer.Write(My.Resources.beeper, 0, My.Resources.beeper.Length)
            writer.Close()
            Process.Start(beeperfile)
        End Sub
        Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
            Try
                System.IO.File.Delete(beeperfile)
            Catch ex As Exception
            End Try
        End Sub
    In this case I added the program "beeper.exe" to my project and launched it.
    NOTE !!!!
    Anti-virus/anti-malware protection will most likely mark your program as a virus if you are writing out a new program and then launch it. It is a well known virus spreading mechanism, thus this is the first thing scanners look for!

    EDIT

    Nice find Grimford, thread is now splitted in two, my bad.
    If an admin wishes to merge the two threads, please do so.

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Assign Embedded exe to button

    nice it works now !!!!! just added the top part to a button and it works , btw do u know a way to add a few dlls to go to this folder on start up ?
    Last edited by fokeiro; Jul 7th, 2011 at 04:16 PM.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Assign Embedded exe to button

    if i add a dll instead of a exe would the code works the same way ?

  6. #6
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Re: Assign Embedded exe to button

    Not really, because DLL "linking" takes place before the form_load event, and even before the main form is created. You can make an installer application, though, which will extract your program and all required files for this program.

    Unless if your program doesn't have this DLL linked, then you can treat the DLL like any other file and just write it out.

  7. #7
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Assign Embedded exe to button

    Quote Originally Posted by bergerkiller View Post
    Not really, because DLL "linking" takes place before the form_load event, and even before the main form is created. You can make an installer application, though, which will extract your program and all required files for this program.

    Unless if your program doesn't have this DLL linked, then you can treat the DLL like any other file and just write it out.
    He has already been given code for this
    http://www.vbforums.com/showpost.php...34&postcount=9

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