大网数据广告活动
网络与域名解析

Creating a Job

· 52CE 我爱测

To create a transfer job, call the IBackgroundCopyManager CreateJob method.

To create a transfer job, call the IBackgroundCopyManager::CreateJob method. After BITS creates the job, add files to the job and modify the job's properties as appropriate for your application. To activate the job in the queue, call the IBackgroundCopyJob::Resume method.

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.

  HRESULT hr = S_OK;
  IBackgroundCopyJob* pJob = NULL;
  IBackgroundCopyJob5* pJob5 = NULL;

  hr = pJob->QueryInterface(__uuidof(IBackgroundCopyJob5), (void**)&pJob5);
  pJob->Release();
  if (FAILED(hr))
  {
    wprintf(L"pJob->QueryInterface failed with 0x%x.\n", hr);
    goto cleanup;
  }

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 11/29/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。