The CreateJob method creates a GUID that uniquely identifies the job. You use the GUID to retrieve the job from the transfer queue. The display name that you provide when you create the job is not unique; more than one job can use the same name.
BITS limits the number of jobs in the queue to 300 jobs and the number of jobs that a user can create to 60 job. These limits do not apply to administrators or services. To change these default limits, see Group Policies.
The following example shows how to create a download job. The example assumes the g_pbcm variable is a valid IBackgroundCopyManager interface pointer. For details on how to create the IBackgroundCopyManager interface pointer, see Connecting to the BITS Service.
HRESULT hr;
GUID JobId;
IBackgroundCopyJob* pJob = NULL;
//To create an upload job, replace BG_JOB_TYPE_DOWNLOAD with
//BG_JOB_TYPE_UPLOAD or BG_JOB_TYPE_UPLOAD_REPLY.
hr = g_pbcm->CreateJob(L"MyJobName", BG_JOB_TYPE_DOWNLOAD, &JobId, &pJob);
if (SUCCEEDED(hr))
{
//Save the JobId for later reference.
//Modify the job's property values.
//Add files to the job.
//Activate (resume) the job in the transfer queue.
}
To get the latest IBackgroundCopyJob interface, call the IBackgroundCopyJob::QueryInterface method. The following example shows how to get the IBackgroundCopyJob5 interface.
This module explains the three types of jobs: local jobs, Windows PowerShell remote jobs, and Common Information Model (CIM)/Windows Management Instrumentation (WMI) jobs. These job types form the basis of the Windows PowerShell job system.