Discussion:
Start a new VB Instance
(too old to reply)
Khamis Abuelkomboz
2005-10-10 03:33:34 UTC
Permalink
Hi

I'm doing a plugin for my application in VB6.0 and I'm almost done. However for reasons of not
affecting the current opened project, I want to create a new instance of vb from within my plugin to
open other projects.

Can somebody tell me how to do that? I tried referencing the Class VBIDE.app but didn't find any
thing doing this.

Thanks in Advance
Khamis
--
Try Code-Navigator on http://www.codenav.com
a source code navigating, analysis and developing tool.
It supports following languages:
* C/C++
* Java
* .NET (including CSharp, VB.Net and other .NET components)
* Classic Visual Basic
* PHP, HTML, XML, ASP, CSS
* Tcl/Tk,
* Perl
* Python
* SQL,
* m4 Preprocessor
* Cobol
Giorgio Brausi
2005-10-10 14:00:18 UTC
Permalink
Post by Khamis Abuelkomboz
Hi
I'm doing a plugin for my application in VB6.0 and I'm almost done.
However for reasons of not
Post by Khamis Abuelkomboz
affecting the current opened project, I want to create a new instance of
vb from within my plugin to
Post by Khamis Abuelkomboz
open other projects.
Can somebody tell me how to do that? I tried referencing the Class
VBIDE.app but didn't find any
Post by Khamis Abuelkomboz
thing doing this.
Perhaps this:

===
Dim sRunVB as string , ProjectToOpen as string
sRunVB = <your_programs_path> & "\Microsoft Visual Studio\VB98\VB6.EXE"
ProjectToOpen = "MyProject.vbp"
Shell sRunVB & " " & ProjectToOpen
===
Also, you can retrieve automatically the VB6.EXE folder with a tricks.
The main root in Regedit for Visual Basic is:
"HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0"
Read the value for the key: "TemplatesDirectory" and you get the complete
path. I.e.:
"C:\Programs Files\Microsoft Visual Studio\VB98\Template"
Remove "Template" string from this path and you obtain the path for VB6.EXE

Then the line above become automatically:
sRunVB = "C:\Programs Files\Microsoft Visual Studio\VB98\VB6.EXE"

Giorgio Brausi
www.vbcorner.net
Khamis Abuelkomboz
2005-10-10 18:40:21 UTC
Permalink
Post by Giorgio Brausi
Post by Khamis Abuelkomboz
I'm doing a plugin for my application in VB6.0 and I'm almost done. However for reasons of not
affecting the current opened project, I want to create a new instance of vb from within my plugin to
open other projects.
Can somebody tell me how to do that? I tried referencing the Class VBIDE.app but didn't find any
thing doing this.
===
Dim sRunVB as string , ProjectToOpen as string
sRunVB = <your_programs_path> & "\Microsoft Visual Studio\VB98\VB6.EXE"
ProjectToOpen = "MyProject.vbp"
Shell sRunVB & " " & ProjectToOpen
===
Also, you can retrieve automatically the VB6.EXE folder with a tricks.
"HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0"
Read the value for the key: "TemplatesDirectory" and you get the complete
"C:\Programs Files\Microsoft Visual Studio\VB98\Template"
Remove "Template" string from this path and you obtain the path for VB6.EXE
sRunVB = "C:\Programs Files\Microsoft Visual Studio\VB98\VB6.EXE"
Giorgio Brausi
www.vbcorner.net
Hi Giorgio,

thank you for your advise. running the vb executable is a simple solution, this is not what I'm
looking for. Actually the plugin gets a request to open a project and goes to a specific file
position, so I need after have opened the project to go to that file and position.

My emagine is to start a VB instance and get the object of that instance to be able to deliver some
commands to it.

Something like this:
========
Set newInstance = New AVBInstance
Set vprj = newInstance.VBProjects.AddFromFile(PrjFile)
Set vFile = vprj.Files(sFile)
vFile.Activate
========

Khamis
--
Try Code-Navigator on http://www.codenav.com
a source code navigating, analysis and developing tool.
It supports following languages:
* C/C++
* Java
* .NET (including CSharp, VB.Net and other .NET components)
* Classic Visual Basic
* PHP, HTML, XML, ASP, CSS
* Tcl/Tk,
* Perl
* Python
* SQL,
* m4 Preprocessor
* Cobol
Khamis Abuelkomboz
2005-10-10 18:41:18 UTC
Permalink
Post by Giorgio Brausi
Post by Khamis Abuelkomboz
I'm doing a plugin for my application in VB6.0 and I'm almost done. However for reasons of not
affecting the current opened project, I want to create a new instance of vb from within my plugin to
open other projects.
Can somebody tell me how to do that? I tried referencing the Class VBIDE.app but didn't find any
thing doing this.
===
Dim sRunVB as string , ProjectToOpen as string
sRunVB = <your_programs_path> & "\Microsoft Visual Studio\VB98\VB6.EXE"
ProjectToOpen = "MyProject.vbp"
Shell sRunVB & " " & ProjectToOpen
===
Also, you can retrieve automatically the VB6.EXE folder with a tricks.
"HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0"
Read the value for the key: "TemplatesDirectory" and you get the complete
"C:\Programs Files\Microsoft Visual Studio\VB98\Template"
Remove "Template" string from this path and you obtain the path for VB6.EXE
sRunVB = "C:\Programs Files\Microsoft Visual Studio\VB98\VB6.EXE"
Hi Giorgio,

thank you for your advise. running the vb executable is a simple solution, this is not what I'm
looking for. Actually the plugin gets a request to open a project and goes to a specific file
position, so I need after have opened the project to go to that file and position.

My emagine is to start a VB instance and get the object of that instance to be able to deliver some
commands to it.

Something like this:
========
Set newInstance = New AVBInstance
Set vprj = newInstance.VBProjects.AddFromFile(PrjFile)
Set vFile = vprj.Files(sFile)
vFile.Activate
========

Khamis
--
Try Code-Navigator on http://www.codenav.com
a source code navigating, analysis and developing tool.
It supports following languages:
* C/C++
* Java
* .NET (including CSharp, VB.Net and other .NET components)
* Classic Visual Basic
* PHP, HTML, XML, ASP, CSS
* Tcl/Tk,
* Perl
* Python
* SQL,
* m4 Preprocessor
* Cobol
Giorgio Brausi
2005-10-10 22:00:22 UTC
Permalink
Post by Khamis Abuelkomboz
Hi Giorgio,
thank you for your advise. running the vb executable is a simple solution,
this is not what I'm
Post by Khamis Abuelkomboz
looking for. Actually the plugin gets a request to open a project and goes to a specific file
position, so I need after have opened the project to go to that file and position.
My emagine is to start a VB instance and get the object of that instance
to be able to deliver some
Post by Khamis Abuelkomboz
commands to it.
========
Set newInstance = New AVBInstance
Set vprj = newInstance.VBProjects.AddFromFile(PrjFile)
Set vFile = vprj.Files(sFile)
vFile.Activate
========
Khamis
I don't know if this can be do... I think not.

Giorgio Brausi
www.vbcorner.net/eng
Ole Nielsby
2005-10-10 23:46:37 UTC
Permalink
Post by Khamis Abuelkomboz
I'm doing a plugin for my application in VB6.0 and I'm almost done.
However for reasons of not affecting the current opened project, I
want to create a new instance of vb from within my plugin to open
other projects.
Shell "...\VB6.EXE " & ProjectToOpen
Hi Giorgio,
thank you for your advise. running the vb executable is a simple
solution, this is not what I'm looking for.
Well then, here is a complex solution if that suits you better.

Let your host addin register a helper addin class. This involves 3 steps
(be sure to undo them when your addin is disconnected):

- Use the registry api to register a ProcName to point to a CLSID.
(Don't register any information under the CLSID, you wont' need it.)
- Let the host addin register a class factory for the helper addin
using CoRegisterClassObject.
- Use WritePrivateProfileString to register your VB addin.
Make it run at VB startup.

Then, shell VB6.EXE. (If your addin is in-proc, you can use
GetModuleHandle with a null module to get the VB exe file name.)

This should start a new VB6 instance. The new instance will try
to create the helper plugin via COM. COM will do CreateInstance
on the factory you registered and marshal the object to the new
VB6 instance. When the new VB6 instance connects to your
helper addin, it passes over a pointer its object model, enabling
you to take control.

I haven't tried but I think it might work. Depending on your grasp
of COM, it might take you some time to sort out the details - the
approach I'm suggesting involves hand-coding some of the stuff
which is usually done for you by the VB environment. Perhaps
there is an easier way - I don't know.

HTH/ON
Khamis Abuelkomboz
2005-10-12 12:07:56 UTC
Permalink
Post by Ole Nielsby
Post by Khamis Abuelkomboz
I'm doing a plugin for my application in VB6.0 and I'm almost done.
However for reasons of not affecting the current opened project, I
want to create a new instance of vb from within my plugin to open
other projects.
Shell "...\VB6.EXE " & ProjectToOpen
Hi Giorgio,
thank you for your advise. running the vb executable is a simple
solution, this is not what I'm looking for.
Well then, here is a complex solution if that suits you better.
Let your host addin register a helper addin class. This involves 3 steps
- Use the registry api to register a ProcName to point to a CLSID.
(Don't register any information under the CLSID, you wont' need it.)
- Let the host addin register a class factory for the helper addin
using CoRegisterClassObject.
- Use WritePrivateProfileString to register your VB addin.
Make it run at VB startup.
Then, shell VB6.EXE. (If your addin is in-proc, you can use
GetModuleHandle with a null module to get the VB exe file name.)
This should start a new VB6 instance. The new instance will try
to create the helper plugin via COM. COM will do CreateInstance
on the factory you registered and marshal the object to the new
VB6 instance. When the new VB6 instance connects to your
helper addin, it passes over a pointer its object model, enabling
you to take control.
I haven't tried but I think it might work. Depending on your grasp
of COM, it might take you some time to sort out the details - the
approach I'm suggesting involves hand-coding some of the stuff
which is usually done for you by the VB environment. Perhaps
there is an easier way - I don't know.
HTH/ON
Hi Ole

You suggestion sounds very reasonable, my COM experience wouldn't help me doing this :-(
I fixed this problem by using the registry. Before starting VB I pass the data I need in the
registry with timestamp, when the plugin get loaded after lunched VB, it looks for this data and
goes to the desigred position and file.

Khamis
--
Try Code-Navigator on http://www.codenav.com
a source code navigating, analysis and developing tool.
It supports following languages:
* C/C++
* Java
* .NET (including CSharp, VB.Net and other .NET components)
* Classic Visual Basic
* PHP, HTML, XML, ASP, CSS
* Tcl/Tk,
* Perl
* Python
* SQL,
* m4 Preprocessor
* Cobol
Loading...