
Getting Progress Information from the IronSpigot Chainer
To get progress information from the IronSpigot chainer, you must include the header file MmioChainer.h, which can be found in Visual Studio SDK installation path\VisualStudioIntegration\Common\Inc\.
To use the chainer, subclass the MmioChainer class that is defined in the header file, and a constructor that has two string parameters. The exact form of these strings is not important.
#include <atlstr.h>
#include <stdlib.h>
#include "MmioChainer.h"
class TestChainer : public IronSpigot::MmioChainer
{
TestChainer() : IronSpigot::MmioChainer(L“TheSectionName”, L“TheEventName”)
{}
}
In the subclass, implement the OnProgress and OnFinished methods to get the progress of the installation.
virtual void OnProgress(unsigned char soFar)
{
//add your own code here
printf("Progress: %i ", soFar);
}
virtual void OnFinished(HRESULT hr)
{
//add your own code here
printf("Finished: 0x%x\r\n", hr);
}
Progress information will be returned as an integer from 0 (not started) to 255 (completed).
In the subclass you must also implement a Launch method that invokes the installation process and performs basic cleanup when the process is terminated.
bool Launch()
{
STARTUPINFO si = {0};
si.cb = sizeof(si);
PROCESS_INFORMATION pi = {0};
BOOL b = ::CreateProcess(NULL,
L"vs_shell_isolated.exe -pipe TheSectionName",
NULL, NULL, FALSE, 0, NULL, NULL,
&si,
&pi);
if (b != 0)
{
Run(pi.hProcess);
::CloseHandle(pi.hThread);
::CloseHandle(pi.hProcess);
}
else
{
printf("CreateProcess failed");
}
return b;
}
To call this code, instantiate the subclass and call the Launch method.
TestChainer *chainer = new TestChainer();
chainer->Launch();