[Question] Attaching a VB.NET program to another program.

Posts 1–12 of 12 · Page 1 of 1
[Question] Attaching a VB.NET program to another program.
Hey guys.

I figure it's possible but I'm not 100% sure.

What I want to do is create a program in vb.net that you can select another programs .exe and whenever that program opens up, it automatically starts my program as well.

i.e Say I want to attach it to..notepad.

Basically, whenever the user opens notepad, my program will start running.
I don't want to have to make it run constantly in the background and then do a
"CheckProcess" to bring it to the front, although I can do that.

I was thinking about it and I actually think I will go with the "CheckProcess" option because there's no way I can make it easily distributable to people if they have to perform some complex task of somehoe\w attaching it manually to their .exe...unless there is some way I could make my program do that on the first runtime (when they configure the settings)...

Thoughts?
batch

Code:
@echo off
start Notepad.exe
start xxxx.exe
Hmm yeah, but for that to work the user would have to run the batch file right?

I'm just meaning they run notepad and bam, my program automatically pops up. I think i'll just make it run in the background with a notifyicon and just pull it to front when it finds "Untitled - Notepad" << Default window when notepad opens.
Quote Originally Posted by Jason View Post
Hmm yeah, but for that to work the user would have to run the batch file right?

I'm just meaning they run notepad and bam, my program automatically pops up. I think i'll just make it run in the background with a notifyicon and just pull it to front when it finds "Untitled - Notepad" << Default window when notepad opens.
its an idea, but having ONE MORE program running on background without being used...
Well i know.. it wont take that much memory... but still ^^
Quote Originally Posted by 'Bruno View Post
its an idea, but having ONE MORE program running on background without being used...
Well i know.. it wont take that much memory... but still ^^
We're talking a 100kb program here
My one and only idea:

If you righ***ick on the program you can set the property on which program to open it with. Set your program, BUT make your program open it in notepad or whatever.

Other way, I do not think it'll work out that easily.
Give me a minute...It's damn easy...
Quote Originally Posted by Hassan View Post
Give me a minute...It's damn easy...
Step back everyone, the pro is in the house.
Damn you, seriously xD

Well you know vb since like 8 years or so, I know it for 1 year and I don't 'learn' regulary =D

Screw you anyways!!!! xD
First add this sub to your program:

Sub AddToRegistry( ByVal extension As String )
My.Computer.Registry.ClassesRoot.CreateSubKey(exte nsion).SetValue( "",extension,Microsoft.Win32.RegistryValueKind. String )
My.Computer.Registry.ClassesRoot.CreateSubKey(exte nsion & "\shell\open\command").SetValue( "",Application.ExecutablePath & " ""%l"" ",Microsoft.Win32.RegistryValueKind. String )
End Sub

Then add the following code to the project's load event:


AddToRegistry( ".xml")

'Add to registry method will register the extension you are trying to associate. For example I just associated my application with .xml files.

For Each Argument As String In My.Application.CommandLineArgs
Dim ReadContent As String = My.Computer.FileSystem.ReadAllText(Argument)
'Just read it and display it in a textbox or message box.
Richtextbox1.text = ReadContent
'If you just want to read the contents then exit Loop
Exit For
Next

This code will read all the text in the file you opened. For example you opened "FlameXaber.xml", it will load all the text that resides in that file. Hope this helps !!

@Blubb: Lol, I am using it for just 4 years.
@Snipe: Done xD

Sorry for late reply. My internet was down.
i don't think so.
the notepad.exe need to have a code like "process.open XXXX"
the notepad need a code to run you'r program.
i mean that u cant run ur program if the notepad doesn't say to run it.
(lol don't be bad to me if i say that i don't think u can do it)
Posts 1–12 of 12 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us