Extending Visual Studio to run via custom exe - visual-studio

I want to create a custom VS project that builds a DLL, but when hitting F5 will run a custom executable that I wrote (which gets the DLL path as parameter).
Is this possible? What API should I use?

Yes, it's easy.
In the project properties, in the Debug tab, select the Start Action 'Start external program'. This program must be your executable.

Related

How to debug chained executables in Visual Studio solution

I have two projects in VS2015. The executable from start up project at some point needs to open the output executable from the second project. (by using Process.Start)
How can I debug the second executable as well as the main one? Can VS include the second executable in the output directory and setup debugging automatically?
Either attach the debugger manually after the second process started (using Debug -> Attach to process) or use the Microsoft Child Process Debugging Power Tool

Access dialog of one project from dialog of another project in visual studio c++

I created two separate executables projects using MFC and dialogs.
What I want to do -
Run one project and use its dialog to open another project dialog like on clicking a button in one dialog open another project dialog. I am here talking about another project and not the same project.
Just one executable to access two project dialogs and to call one dialog from another dialog.
Is it possible?? Or do I have to incorporate whole one project into another project??
I am new to visual studio so please suggest something. Thanks
You can't do with the two EXE projects, instead you make one of your projects a DLL and call the DLL from EXE (the DLL will be loaded into the same process space as the EXE). There are a few different ways you can write the DLL, but this is a very big topic. Here's a good starting point on the Microsoft web site:
Microsoft: DLLs in Visual C++
You should consider the mechanism that snowdude has suggested. However, if you need to create multiple executable files (ie. .exe), you can use the LoadLibrary function to gain access to the dialog code in the other executable. LoadLibrary can't be used to run the other executable, but, you can use the GetProcAddress function to provide the address to a function within the other executable that will run the dialog code.

Register type library during installation

I have added an automation interface to an application I wrote. The type library is stored as a resource in the application, and on startup, the application calls RegisterTypeLib to register the type library automatically.
I just discovered that this call to RegisterTypeLib only works during development, where the application is launched from Visual Studio, because Visual Studio is running as administrator, and the application inherits this. When running the debug build from the command line, or when running the application as installed by the installer, the application is not running as administrator, and the call to RegisterTypeLib fails.
So I suppose I should register the type library during installation (which would also have the nice side effect of making the automation interface available without having to run the application first). The installer is a Windows Installer project in Visual Studio.
Is it possible to do achieve the effect of RegisterTypeLib during installation (and if yes, how)? When the installer solution is open, Visual Studio shows an editor called "Registry" wher one can add keys to the registry, but there's no way I can add each key separately - I need to somehow add the entire type library with a single call, like RegisterTypeLib does.
EDIT: After manuell's hint and some research of my own, the question boils down to this:
I need to call MyApp /RegServer from the installer (which will also create other required registry keys that aren't created by RegisterTypeLib); how exactly does one do this? I added an "Install" custom action in the Visual Studio installer solution, but haven't yet found out how to trigger it.
The usal way is to let the installer launch the application with the command line arguments /regserver or /unregserver. If you use a Framework (MFC/ATL), the handling of all the registration (unregistration) steps are done automatically.
If you want to do all by your self, check the arguments to "main", and call RegisterTypeLib. The Windows installer should launch your EXE with /regserver, if it knows that's a com server.

Run multiple instances with one click in Visual Studio

I wonder if I can run multiple instances (right now two instances) of my application in debug mode by doing a simple click or set a key for that...
Not many people seem to know this, but this is perfectly possible, though I admit it's not very obvious.
Here's what you do:
suppose your current project is A, and it's output is c:\bin\my.exe
add an empty project to the solution for A, call it 'Dummy'
under Dummy's Project Properties->Debugging set the Command to point c:\bin\my.exe
under Solution Properties->Configuration Manager, uncheck all builds of the Dummy project so VS won't try to build it (building an empty project fails)
under Solution Properties->Startup Project, select Multiple Startup Projects and set the Action for both A and Dummy to Start
now hit F5 and your exe will be launched twice, each under a seperate debugging instance. (as you will be able to see in the Debug->View->Processes window)
You can use "Multiple Startup Projects" feature, but avoid creating dummy projects by hand: just add your debuggee executable into the solution directly:
Solution > Add existing project > Path to .exe
If you neeed several instances, Visual Studio won't allow you to add the same executable twice, but adding a symlink to it with another name works as expected.
MSDN: How to: Debug an Executable Not Part of a Visual Studio Solution
Is Visual Studio 2013 this is even easier!
Project-> Properties -> Debug -> check "Start external program" and click the ... button, navigate to your .exe of the other program.
Then Make sure in your Solution -> Properties -> MultipleStartup Projects that it's checked.
You can run two instances of your application from where it is built; example: d:\test\bin\debug\app.exe and attach both instances to the Visual Studio 2010 debugger.

Execute an script/application after installing (using VS Setup Project)

I need to execute a Console Application script after installing my application. Depending on the Windows version, it adds some data to the Registry.
How can I do this using a Visual Studio Setup Project?
Note:
I'm saying after because I read in How to execute custom action before installing files when using VS's Setup Project? that it isn't possible to do it before, but it doesn't really matter in my case.
Simply add the custom action under Install node. I don't really understand what you mean by "console application script", but if you mean a BAT file you can write a custom EXE which launches it through ShellExecute.
If you are using a DLL, make sure that "InstallerClass" custom action property is set correctly:
False for Win32 DLLs
True for .NET Installer Class actions

Resources