当前位置: 首页>>代码示例>>C++>>正文


C++ IBackgroundCopyJob::Release方法代码示例

本文整理汇总了C++中IBackgroundCopyJob::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IBackgroundCopyJob::Release方法的具体用法?C++ IBackgroundCopyJob::Release怎么用?C++ IBackgroundCopyJob::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBackgroundCopyJob的用法示例。


在下文中一共展示了IBackgroundCopyJob::Release方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _tmain

/*
 * Main program entry point
 */
int _tmain(int argc, _TCHAR* argv[])
{
    HRESULT hr;
    IBackgroundCopyManager *Manager;

    // Get the BITS Background Copy Manager 
    hr = GetBackgroundCopyManager(&Manager);
    if( SUCCEEDED( hr ) )
    {
        IBackgroundCopyJob *Job;

        // Create a new download job
        hr = CreateDownloadJob( L"MyJob", Manager, &Job );
        if( SUCCEEDED(hr) )
        {
            // Add the files to the job
            for( int i=0; i<ARRAY_LENGTH(FileList); ++i)
            {
                hr = Job->AddFile(
                            FileList[i].RemoteFile,
                            FileList[i].LocalFile
                            );

                if( FAILED(hr) )
                {
                    printf(
                        "Error: Unable to add remote file '%ws' to the download job (error %08X).\n",
                        FileList[i].RemoteFile,
                        hr
                        );
                }
                else
                {
                    printf( 
                        "Downloading remote file '%ws' to local file '%ws'\n",
                        FileList[i].RemoteFile,
                        FileList[i].LocalFile
                        );
                }
            }


            // Start the job and display its progress
            hr = Job->Resume();
            if( FAILED(hr) )
            {
                printf( "ERROR: Unable to start the BITS download job (error code %08X).\n", hr );
            }
            else
            {
                MonitorJobProgress( Job );
            }

            // Release the BITS IBackgroundCopyJob interface
            Job->Release();
            Job = NULL;
        }

        // Release the IBackgroundCopyManager interface
        Manager->Release();
        Manager = NULL;
    }

    return 0;
}
开发者ID:9578577,项目名称:Windows-classic-samples,代码行数:68,代码来源:BACKGROUNDCOPYFILEPROPERTIES.cpp

示例2: _tmain

void _cdecl _tmain(int argc, LPWSTR* argv)
{	
    GUID guidJob;
    HRESULT hr;
	IBackgroundCopyManager *pQueueMgr;
	IBackgroundCopyJob* pJob = NULL;
    CNotifyInterface *pNotify;

    if (argc != 3)
    {
        wprintf(L"Usage:");
        wprintf(L"%s", argv[0]);
        wprintf(L"[remote name] [local name]\n");
        goto finished;
    }

    //Specify the COM threading model.
    hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    if (SUCCEEDED(hr))
    {
        //The impersonation level must be at least RPC_C_IMP_LEVEL_IMPERSONATE.
        hr = CoInitializeSecurity(NULL, -1, NULL, NULL,
             RPC_C_AUTHN_LEVEL_CONNECT,
             RPC_C_IMP_LEVEL_IMPERSONATE,
             NULL, EOAC_NONE, 0);

        if (SUCCEEDED(hr))
        {

	        // Connect to BITS
            hr = CoCreateInstance(__uuidof(BackgroundCopyManager), NULL,
                CLSCTX_LOCAL_SERVER,
                __uuidof(IBackgroundCopyManager),
                (void **)&pQueueMgr);

	        if (FAILED(hr))
	        {
		        // Failed to connect
                wprintf(L"Failed to connect to BITS.Error: 0x%x\n",hr);
		        goto done;
	        }
        }
        else
        {
            //Failed to impersonate
            wprintf(L"CoInitializeSecurity Failed. Error:0x%x\n",hr);
            goto done;
        }
    }
    else
    {
        wprintf(L"CoInitializeEx Failed. Error:0x%x",hr);
        goto done;
    }

	// Create a Job
    wprintf(L"Creating Job...\n");
    hr = pQueueMgr->CreateJob(L"P2PSample",
         BG_JOB_TYPE_DOWNLOAD,
         &guidJob,
         &pJob);
	
    // Free Resources
    pQueueMgr->Release();

	if(FAILED(hr))
    {   
        wprintf(L"Create Job failed with error: %x\n",hr);
    	goto done;
    }
    
    // Set the File Completed Call
    pNotify = new CNotifyInterface();
    if (pNotify)
    {
        hr = pJob->SetNotifyInterface(pNotify);
        if (SUCCEEDED(hr))
        {
            hr = pJob->SetNotifyFlags(BG_NOTIFY_JOB_TRANSFERRED | 
                                BG_NOTIFY_JOB_ERROR);
        }

        // Free resouces
        pNotify->Release();
        pNotify = NULL;

        if (FAILED(hr))
        {
            wprintf(L"Unable to register callbacks\nError: %x\n",hr);
            wprintf(L"Cancelling job\n");
            goto cancel;
        }
    }
    else
    {
        wprintf(L"Could not create the Notification Interface\n");
        wprintf(L"Cancelling job\n");
        goto cancel;
    }
	// Add a File
//.........这里部分代码省略.........
开发者ID:Ippei-Murofushi,项目名称:WindowsSDK7-Samples,代码行数:101,代码来源:DOWNLOADS.cpp


注:本文中的IBackgroundCopyJob::Release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。