|
-
Jul 7th, 2011, 06:26 AM
#1
Thread Starter
Member
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 ?
-
Jul 7th, 2011, 06:38 AM
#2
Re: Assign Embedded exe to button
I'm sure I have seen another thread like this..
O yes, its yours! Link
-
Jul 7th, 2011, 06:43 AM
#3
Fanatic Member
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.
-
Jul 7th, 2011, 03:41 PM
#4
Thread Starter
Member
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.
-
Jul 8th, 2011, 06:31 AM
#5
Thread Starter
Member
Re: Assign Embedded exe to button
if i add a dll instead of a exe would the code works the same way ?
-
Jul 9th, 2011, 08:08 AM
#6
Fanatic Member
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.
-
Jul 9th, 2011, 09:27 AM
#7
Re: Assign Embedded exe to button
 Originally Posted by bergerkiller
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|