NDEVR
API Documentation
ApplicationResource

High-Level functions for communicating with the operating system or getting general information about the application. More...

Collaboration diagram for ApplicationResource:
[legend]

Public Types

enum class  InstanceType
 The scope or level at which a global lock is acquired.
enum class  ReleaseType
 The release maturity level of the application build.
enum  UIMode
 The user interface mode the application is running in.

Static Public Member Functions

static String AppContextName (bool lower_case)
 Returns the application context name, optionally in lower case.
static String ApplicationDisplayName ()
 Returns the translated application name plus (beta) or (alpha) depending on the type.
static TranslatedString ApplicationNameAndVersion ()
 Returns the translated application name combined with the version string.
static Time BuildTime ()
 Returns the timestamp of when the application was built.
static void CloseApp (bool relaunch=false, const StringView &relaunch_options="--relaunch")
 Closes the application, optionally relaunching it with the given options.
static void FactoryResetApp ()
 Resets the application to its factory default state.
static Buffer< uint01GetAppBundledResource (void *handle, const StringView &type, const StringView &name)
 Retrieves an embedded resource from the application bundle.
static File GetDefaultOSApplicationForExtension (const StringView &extension)
 Returns the default OS application registered for the given file extension.
static TranslatedString GetErrorString (sint08 result)
 Returns a translated error description for the given error code.
static HardwareInformation GetHardwareInformation ()
 Retrieves information about the system hardware.
static TranslatedString GetLastErrorString ()
 Returns a translated description of the last system error.
static OSInformation GetOSInformation ()
 Retrieves information about the current operating system.
static Buffer< VideoCardInformationGetVideoCardInfo ()
 Retrieves information about all detected video cards in the system.
static bool GlobalLock (StringView guid, InstanceType kind=InstanceType::e_system)
 Attempts to lock on a guid that is shared across applications.
static bool IsFirstTimeRunning ()
 Checks whether this is the first time the application has been run.
static bool IsOSLanguageInstalled (String language)
 Checks whether a given language is installed on the operating system.
static void LogApplicationInformation (LogPtr log)
 Logs general application information to the specified log.
static void LogComputerInformation (LogPtr log)
 Logs computer hardware information to the specified log.
static void LogOSInformation (LogPtr log)
 Logs operating system information to the specified log.
static void LogUserSettings (LogPtr log, bool log_only_non_defaults)
 Logs user settings to the specified log.
static String MakeSafeForCommandLine (StringView var)
 Takes a string which may have spaces, etc, and wraps it as needed such that it is safe to execute on the command line.
static void OpenExplorerWindow (const StringView &location)
 Opens the operating system's file explorer at the specified location.
static void OpenFile (const File &file)
 Opens a file using the default OS application associated with its type.
static void OpenOSBluetoothDialog ()
 Opens the operating system's Bluetooth settings dialog.
static void OpenOSClockDialog ()
 Opens the operating system's clock or date/time settings dialog.
static void OpenOSFileSystemDialog ()
 Opens the operating system's file system or storage management dialog.
static void OpenOSLanguageDialog ()
 Opens the operating system's language settings dialog.
static void OpenOSLocationDialog ()
 Opens the operating system's location services settings dialog.
static void OpenOSPrinterDialog ()
 Opens the operating system's printer settings dialog.
static void OpenOSWifiDialog ()
 Opens the operating system's Wi-Fi settings dialog.
static String OSUserName ()
 Returns the current operating system user name.
static void ReadUserOptions ()
 Reads user options and settings from persistent storage.
static uint04 RecommendedThreadCount ()
 Returns the recommended number of threads based on the system hardware.
static void SaveUserOptions (bool is_shutting_down)
 Saves all user options and settings to persistent storage.
static void SendFile (const File &file)
 Sends a file using the OS sharing or email mechanism.
static UUID SessionID ()
 Returns the unique identifier for the current application session.
static Time SessionStartTime ()
 Returns the timestamp of when the current session started.
static void SetFolderIcon (const File &folder, const File &icon)
 Sets a custom icon for a folder in the OS file system.
static bool SetupAsConsole (bool is_console)
 Configures the application to run as a console (non-GUI) process.
static void ShareFileWithMediaServer (const File &file)
 Shares a file with the platform's media server or sharing service.

Static Public Attributes

static Resource< Stringactivation_code
 The license activation code for the application.
static Resource< TranslatedStringapplication_name
 The display name of the application.
static Resource< Stringapplication_version
 The current version string of the application.
static ApplicationOption< Timecurrent_run_time
 The timestamp of the current application run.
static ApplicationOption< bool > has_finished_initial_setup
 Whether the first-time setup wizard has completed.
static ApplicationOption< Stringlast_application_version
 The version string from the previous application run.
static bool last_proper_shutdown
 Cached value of whether the previous session shut down properly.
static Time last_run_time
 Timestamp of the previous application run.
static Resource< PasswordStringpassword
 The logged-in user's password credential.
static ApplicationOption< bool > proper_shutdown
 Whether the application shut down properly last time.
static Resource< ReleaseTyperelease_type
 The release maturity level of this build.
static Resource< Buffer< String > > startup_options
 Command-line options passed at application startup.
static Resource< Stringuser_email
 The logged-in user's email address.
static Resource< Stringusername
 The logged-in user's username.

Detailed Description

High-Level functions for communicating with the operating system or getting general information about the application.


Definition at line 150 of file ApplicationResource.h.

Member Function Documentation

◆ AppContextName()

String ApplicationResource::AppContextName ( bool lower_case)
static

Returns the application context name, optionally in lower case.

Parameters
[in]lower_caseWhether to return the name in all lower case.
Returns
The application context name as a String.

◆ ApplicationDisplayName()

String ApplicationResource::ApplicationDisplayName ( )
static

Returns the translated application name plus (beta) or (alpha) depending on the type.


◆ ApplicationNameAndVersion()

TranslatedString ApplicationResource::ApplicationNameAndVersion ( )
static

Returns the translated application name combined with the version string.

Returns
A TranslatedString containing the application name and version.

◆ BuildTime()

Time ApplicationResource::BuildTime ( )
static

Returns the timestamp of when the application was built.

Returns
The build time as a Time object.

◆ CloseApp()

void ApplicationResource::CloseApp ( bool relaunch = false,
const StringView & relaunch_options = "--relaunch" )
static

Closes the application, optionally relaunching it with the given options.

Parameters
[in]relaunchWhether to relaunch the application after closing.
[in]relaunch_optionsCommand-line options to pass when relaunching.

◆ GetAppBundledResource()

Buffer< uint01 > ApplicationResource::GetAppBundledResource ( void * handle,
const StringView & type,
const StringView & name )
static

Retrieves an embedded resource from the application bundle.

Parameters
[in]handlePlatform-specific handle to the application module.
[in]typeThe resource type identifier.
[in]nameThe resource name identifier.
Returns
A byte buffer containing the raw resource data.

◆ GetDefaultOSApplicationForExtension()

File ApplicationResource::GetDefaultOSApplicationForExtension ( const StringView & extension)
static

Returns the default OS application registered for the given file extension.

Parameters
[in]extensionThe file extension to look up (e.g., ".pdf").
Returns
A File representing the default application executable.

◆ GetErrorString()

TranslatedString ApplicationResource::GetErrorString ( sint08 result)
static

Returns a translated error description for the given error code.

Parameters
[in]resultThe error code to translate.
Returns
The error description as a TranslatedString.

◆ GetHardwareInformation()

HardwareInformation ApplicationResource::GetHardwareInformation ( )
static

Retrieves information about the system hardware.

Returns
A HardwareInformation struct populated with the current hardware details.

◆ GetLastErrorString()

TranslatedString ApplicationResource::GetLastErrorString ( )
static

Returns a translated description of the last system error.

Returns
The last error message as a TranslatedString.

◆ GetOSInformation()

OSInformation ApplicationResource::GetOSInformation ( )
static

Retrieves information about the current operating system.

Returns
An OSInformation struct populated with the current OS details.

◆ GetVideoCardInfo()

Buffer< VideoCardInformation > ApplicationResource::GetVideoCardInfo ( )
static

Retrieves information about all detected video cards in the system.

Returns
A buffer of VideoCardInformation for each detected video card.

◆ GlobalLock()

bool ApplicationResource::GlobalLock ( StringView guid,
InstanceType kind = InstanceType::e_system )
static

Attempts to lock on a guid that is shared across applications.


Returns
true if able to lock, false means another application has already locked on this guid.

◆ IsFirstTimeRunning()

bool ApplicationResource::IsFirstTimeRunning ( )
static

Checks whether this is the first time the application has been run.

Returns
true if the application has not been run before, false otherwise.

◆ IsOSLanguageInstalled()

bool ApplicationResource::IsOSLanguageInstalled ( String language)
static

Checks whether a given language is installed on the operating system.

Parameters
[in]languageThe language identifier to check.
Returns
true if the language is installed, false otherwise.

◆ LogApplicationInformation()

void ApplicationResource::LogApplicationInformation ( LogPtr log)
static

Logs general application information to the specified log.

Parameters
[in]logThe log target to write application information to.

◆ LogComputerInformation()

void ApplicationResource::LogComputerInformation ( LogPtr log)
static

Logs computer hardware information to the specified log.

Parameters
[in]logThe log target to write hardware information to.

◆ LogOSInformation()

void ApplicationResource::LogOSInformation ( LogPtr log)
static

Logs operating system information to the specified log.

Parameters
[in]logThe log target to write OS information to.

◆ LogUserSettings()

void ApplicationResource::LogUserSettings ( LogPtr log,
bool log_only_non_defaults )
static

Logs user settings to the specified log.

Parameters
[in]logThe log target to write settings to.
[in]log_only_non_defaultsWhether to log only settings that differ from defaults.

◆ MakeSafeForCommandLine()

String ApplicationResource::MakeSafeForCommandLine ( StringView var)
static

Takes a string which may have spaces, etc, and wraps it as needed such that it is safe to execute on the command line.


If the string has spaces, the returned variable will be wrapped in quotes.

Warning
Commands ending with a \ and needing quotes might behave differently on different platforms.

◆ OpenExplorerWindow()

void ApplicationResource::OpenExplorerWindow ( const StringView & location)
static

Opens the operating system's file explorer at the specified location.

Parameters
[in]locationThe directory path to open in the explorer window.

◆ OpenFile()

void ApplicationResource::OpenFile ( const File & file)
static

Opens a file using the default OS application associated with its type.

Parameters
[in]fileThe file to open.

◆ OSUserName()

String ApplicationResource::OSUserName ( )
static

Returns the current operating system user name.

Returns
The OS-level user name as a String.

◆ RecommendedThreadCount()

uint04 ApplicationResource::RecommendedThreadCount ( )
static

Returns the recommended number of threads based on the system hardware.

Returns
The recommended thread count.

◆ SaveUserOptions()

void ApplicationResource::SaveUserOptions ( bool is_shutting_down)
static

Saves all user options and settings to persistent storage.

Parameters
[in]is_shutting_downWhether the application is in the process of shutting down.

◆ SendFile()

void ApplicationResource::SendFile ( const File & file)
static

Sends a file using the OS sharing or email mechanism.

Parameters
[in]fileThe file to send.

◆ SessionID()

UUID ApplicationResource::SessionID ( )
static

Returns the unique identifier for the current application session.

Returns
A UUID representing this session.

◆ SessionStartTime()

Time ApplicationResource::SessionStartTime ( )
static

Returns the timestamp of when the current session started.

Returns
The session start time as a Time object.

◆ SetFolderIcon()

void ApplicationResource::SetFolderIcon ( const File & folder,
const File & icon )
static

Sets a custom icon for a folder in the OS file system.

Parameters
[in]folderThe folder to set the icon for.
[in]iconThe icon file to use.

◆ SetupAsConsole()

bool ApplicationResource::SetupAsConsole ( bool is_console)
static

Configures the application to run as a console (non-GUI) process.

Parameters
[in]is_consoleWhether to enable console mode.
Returns
true if the console was set up successfully.

◆ ShareFileWithMediaServer()

void ApplicationResource::ShareFileWithMediaServer ( const File & file)
static

Shares a file with the platform's media server or sharing service.

Parameters
[in]fileThe file to share.

The documentation for this class was generated from the following file: