Skip to main content

VelopackApp class

VelopackApp helps you to handle app activation events correctly.

class VelopackApp

Remarks

This should be used as early as possible in your application startup code. (eg. the beginning of main() or wherever your entry point is) To use this class, you should create a new VelopackApp::Build() builder instance, and then chain calls to the builder to configure your app. Finally, call the Run() method to execute the Velopack logic.

Methods

MethodSummary
BuildCreate and return a new VelopackApp builder.
SetLoggerAttach a custom callback to receive log messages from Velopack.
SetAutoApplyOnStartupSet whether to automatically apply downloaded updates on startup. This is ON by default.
SetArgsOverride the command line arguments used by VelopackApp. By default, Velopack will use the command line arguments from the current process.
SetLocatorOverride the default VelopackLocator. The locator is used to find important paths for the application.
OnAfterInstallThis hook is triggered after the app has been installed. WARNING: This hook is run during critical stages of Velopack operations. Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.
OnBeforeUninstallThis hook is triggered before the app is uninstalled. WARNING: This hook is run during critical stages of Velopack operations. Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.
OnBeforeUpdateThis hook is triggered before the app is updated. WARNING: This hook is run during critical stages of Velopack operations. Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.
OnAfterUpdateThis hook is triggered after the app is updated. WARNING: This hook is run during critical stages of Velopack operations. Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.
OnFirstRunThis hook is triggered when the application is started for the first time after installation.
OnRestartedThis hook is triggered when the application is restarted by Velopack after installing updates.
RunRuns the Velopack startup logic. This should be the first thing to run in your app. In some circumstances it may terminate/restart the process to perform tasks.

Build()

static Velopack::VelopackApp Build();

Create and return a new VelopackApp builder.

SetLogger()

Velopack::VelopackApp& SetLogger(vpkc_log_callback_t cbInstall, void* p_user_data);

Attach a custom callback to receive log messages from Velopack.

SetAutoApplyOnStartup()

Velopack::VelopackApp& SetAutoApplyOnStartup(bool bAutoApply);

Set whether to automatically apply downloaded updates on startup. This is ON by default.

SetArgs(args)

Velopack::VelopackApp& SetArgs(std::vector<std::string> const& args);

Override the command line arguments used by VelopackApp. By default, Velopack will use the command line arguments from the current process.

Parameters

NameDescription
argsThe command line arguments to use.

Returns A reference to the builder.

SetLocator(locator)

Velopack::VelopackApp& SetLocator(Velopack::VelopackLocatorConfig const& locator);

Override the default VelopackLocator. The locator is used to find important paths for the application.

Parameters

NameDescription
locatorThe locator to use.

Returns A reference to the builder.

OnAfterInstall(cbAfterInstall)

Velopack::VelopackApp& OnAfterInstall(vpkc_hook_callback_t cbAfterInstall);

This hook is triggered after the app has been installed. WARNING: This hook is run during critical stages of Velopack operations. Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.

Parameters

NameDescription
cbAfterInstallThe callback to run after the app has been installed.

Returns A reference to the builder.

OnBeforeUninstall(cbBeforeUninstall)

Velopack::VelopackApp& OnBeforeUninstall(vpkc_hook_callback_t cbBeforeUninstall);

This hook is triggered before the app is uninstalled. WARNING: This hook is run during critical stages of Velopack operations. Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.

Parameters

NameDescription
cbBeforeUninstallThe callback to run before the app is uninstalled.

Returns A reference to the builder.

OnBeforeUpdate(cbBeforeUpdate)

Velopack::VelopackApp& OnBeforeUpdate(vpkc_hook_callback_t cbBeforeUpdate);

This hook is triggered before the app is updated. WARNING: This hook is run during critical stages of Velopack operations. Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.

Parameters

NameDescription
cbBeforeUpdateThe callback to run before the app is updated.

Returns A reference to the builder.

OnAfterUpdate(cbAfterUpdate)

Velopack::VelopackApp& OnAfterUpdate(vpkc_hook_callback_t cbAfterUpdate);

This hook is triggered after the app is updated. WARNING: This hook is run during critical stages of Velopack operations. Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.

Parameters

NameDescription
cbAfterUpdateThe callback to run after the app is updated.

Returns A reference to the builder.

OnFirstRun(cbFirstRun)

Velopack::VelopackApp& OnFirstRun(vpkc_hook_callback_t cbFirstRun);

This hook is triggered when the application is started for the first time after installation.

Parameters

NameDescription
cbFirstRunThe callback to run when the application is started for the first time.

Returns A reference to the builder.

OnRestarted(cbRestarted)

Velopack::VelopackApp& OnRestarted(vpkc_hook_callback_t cbRestarted);

This hook is triggered when the application is restarted by Velopack after installing updates.

Parameters

NameDescription
cbRestartedThe callback to run when the application is restarted.

Returns A reference to the builder.

Run(pUserData)

void Run(void* pUserData = 0);

Runs the Velopack startup logic. This should be the first thing to run in your app. In some circumstances it may terminate/restart the process to perform tasks.

Parameters

NameDescription
pUserDataA pointer to user data that will be passed to any hooks that are executed.

Generated from Velopack (C++ headers)