Export (0) Print
Expand All

IBackgroundCopyFile2::GetFileRanges method

Retrieves the ranges that you want to download from the remote file.

Syntax


HRESULT GetFileRanges(
  [in, out]  DWORD *RangeCount,
  [out]      BG_FILE_RANGE **Ranges
);

Parameters

RangeCount [in, out]

Number of elements in Ranges.

Ranges [out]

Array of BG_FILE_RANGE structures that specify the ranges to download. When done, call the CoTaskMemFree function to free Ranges.

Return value

This method returns the following return values, as well as others.

Return codeDescription
S_OK

Success

S_FALSE

No ranges were specified or the job is an upload or upload-reply job. RangeCount is set to zero and Ranges is set to NULL.

 

Examples

The following example shows how to call the GetFileRanges method to retrieve the ranges of a file that you requested BITS to download. The example assumes you have enumerated the files in the job and retrieved an IBackgroundCopyFile interface pointer.



    IBackgroundCopyFile* pFile;
    IBackgroundCopyFile2* pFile2 = NULL;
    BG_FILE_RANGE* pRanges = NULL;
    DWORD dwRangeCount = 0;

    //Need to query the IBackgroundCopyFile interface for an IBackgroundCopyFile2
    //interface pointer. The IBackgroundCopyFile2 interface contains the GetFileRanges method.
    hr = pFile->QueryInterface(__uuidof(IBackgroundCopyFile2), (void**)&pFile2);
    if (S_OK == hr)
    {
        hr = pFile2->GetFileRanges(&dwRangeCount, &pRanges);
        if (S_OK == hr)
        {
            for (DWORD i=0; i<dwRangeCount; i++)
            {
                wprintf(L"offset: %I64u length: ", pRanges[i].InitialOffset);
                if (BG_LENGTH_TO_EOF == pRanges[i].Length)
                {
                    wprintf(L"EOF\n");
                }
                else
                {
                    wprintf(L"%I64u\n", pRanges[i].Length);
                }
            }
            CoTaskMemFree(pRanges);
        }
        else if (S_FALSE == hr)
        {
            wprintf(L"No ranges specified for file.\n");
        }
        else
        {
            //Handle error.
        }

        hr = pFile2->Release();
        pFile2 = NULL;
    }
    else
    {
        //Handle error. QueryInterface will return E_NOINTERFACE if the version of BITS
        //running on the computer is less than BITS 2.0.
    }

    pFile->Release(); 
    pFile = NULL;


Requirements

Minimum supported client

Windows Vista, Windows XP with SP2

Minimum supported server

Windows Server 2008, Windows Server 2003 with SP1

Version

KB842773 on Windows Server 2003, and Windows XP

Header

Bits2_0.h (include Bits.h)

IDL

Bits2_0.idl

Library

Bits.lib

DLL

BitsPrx3.dll

IID

IID_IBackgroundCopyFile2 is defined as 83E81B93-0873-474D-8A8C-F2018B1A939C

See also

BG_FILE_RANGE
IBackgroundCopyJob3::AddFileWithRanges
IBackgroundCopyFile2

 

 

Community Additions

ADD
Show:
© 2014 Microsoft