TWUOpenSession

The TWUOpenSession function opens a Tarma WebUpdate session and connects to the remote (or local) server that will be used to obtain the update packages. The session must eventually be closed by a call to TWUCloseSession.

Tip: TWUOpenUpdateURL combines the functionality of TWUOpenSession and TWUGetPIF. You might find it more convenient to use that function.

URESULT TWUOpenSession(
    eTWUProtocol eProtocol,
    int nPortNumber,
    const TCHAR *pszServerName,
    const TCHAR *pszUserName,
    const TCHAR *pszPassword,
    fTWUCallback pfCallback,
    LPARAM lCallbackCookie,
    HWND hwndParent,
    TWUHANDLE *phSession
);

Delphi version:

function TWUOpenSession(
    eProtocol: eTWUProtocol;
    nPortNumber: Integer;
    pszServerName: PTCHAR;
    pszUserName: PTCHAR;
    pszPassword: PTCHAR;
    pfCallback: fTWUCallback;
    lCallbackCookie: LPARAM;
    hwndParent: HWND;
    var phSession: TWUHANDLE
): URESULT;

Parameters

eProtocol
[Input] Protocol identifier; see Protocol identifiers below.
nPortNumber
[Input] TCP/IP port number to use for the connection, or TWU_DEFAULT_PORT to use the default port number for the given protocol.
pszServerName
[Input] Host name of the remote server to use, without protocol specifier or trailing path, for example www.tarma.com
pszUserName
[Input, optional] User name for the connection, if the connection requires some form of authentication.
pszPassword
[Input, optional] Password for the connection, if the connection requires some form of authentication.
pCallback
[Input] Pointer to the callback function that will be called when significant events occur and when progress is being made during file downloads. If you set this parameter to NULL, no callback function will be called.
lCallbackCookie
[Input] User-defined value that will be passed unchanged to the callback function. You can use this cookie to pass additional information to the callback function.
hwndParent
[Input] Handle of parent window for the session, or NULL if there is no parent window. The parent window handle is used if a message box or some similar window must be displayed during the session; in that case, the parent window is disabled while the secondary window is active.
phSession
[Output] Pointer to a variable that receives the session handle if the session could be opened.

Return value

If the function succeeds, it returns ERROR_SUCCESS (0). If it fails, it returns a nonzero Win32 API error code. You can use TWUGetErrorMessage to retrieve the error message that corresponds to the error code.

Protocol identifiers

To specify the desired communication protocol, use one of the following protocol identifiers.

Identifier Description
kTWUProtocolNone Not a valid protocol identifier
kTWUProtocolFile Use local or remote file system (including UNC paths)
kTWUProtocolFTP Use FTP protocol
kTWUProtocolHTTP Use HTTP protocol
kTWUProtocolHTTPS Use HTTPS protocol