TWUCloseUpdate

The TWUCloseUpdate function ends the high-level Tarma WebUpdate session and optionally restarts the application.

URESULT TWUCloseUpdate(
    TWUPDATE hUpdate
);

Parameters

hUpdate
[Input] Handle of active update session. This handle will be closed and no other functions may be called with the handle.

Return value

If the function succeeds, it returns ERROR_SUCCESS (0). If the function fails, it returns a nonzero Win32 API error code. You can use TWUGetErrorMessage to retrieve the error message that corresponds to the error code. See the Remarks section for situations that could cause an error code to be returned.

Remarks

If a restart is scheduled (through a prior call to TWURegisterRestart), then the following will happen during the TWUCloseUpdate call.

  1. Your application's main window is re-enabled, if necessary.
  2. [If TWU_UFLAGS_IMMEDIATE was specified in TWURegisterRestart] The registered restart application is started immediately.
  3. [If TWU_UFLAGS_CLOSEMAIN was specified in TWURegisterRestart] The TWUCloseUpdate function posts a WM_CLOSE message to your main window. The normal response to this message is that your application will close, possibly after saving modified documents or after asking the user for confirmation.

After the TWUCloseUpdate function returns, the Windows message loop in your application will pick up the WM_CLOSE message and start the application shutdown process. As soon as the main window is destroyed, the registered restart application is started. It is therefore important that your application fully exits shortly after the WM_CLOSE message is processed.

If an application restart is scheduled but the TWUCloseUpdate function cannot post the WM_CLOSE message, it will return a nonzero error code. In that case, your application should ask the user to perform its own restart (or your application should do so automatically). It should also do this if neither TWU_UFLAGS_CLOSEMAIN nor TWU_UFLAGS_IMMEDIATE were specified in TWURegisterRestart, because in that case the TWU library cannot start the registered restart application itself.