本文整理汇总了C++中IBackgroundCopyJob::SetNotifyInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ IBackgroundCopyJob::SetNotifyInterface方法的具体用法?C++ IBackgroundCopyJob::SetNotifyInterface怎么用?C++ IBackgroundCopyJob::SetNotifyInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBackgroundCopyJob
的用法示例。
在下文中一共展示了IBackgroundCopyJob::SetNotifyInterface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyCom_BuildPyException
// @pymethod |PyIBackgroundCopyJob|SetNotifyInterface|Description of SetNotifyInterface.
PyObject *PyIBackgroundCopyJob::SetNotifyInterface(PyObject *self, PyObject *args)
{
IBackgroundCopyJob *pIBCJ = GetI(self);
if ( pIBCJ == NULL )
return NULL;
// @pyparm <o PyIUnknown *>|Val||Description for Val
PyObject *obVal;
IUnknown *Val;
if ( !PyArg_ParseTuple(args, "O:SetNotifyInterface", &obVal) )
return NULL;
BOOL bPythonIsHappy = TRUE;
if (!PyCom_InterfaceFromPyInstanceOrObject(obVal, IID_IUnknown, (void **)&Val, TRUE /* bNoneOK */))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIBCJ->SetNotifyInterface( Val );
if (Val) Val->Release();
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob );
Py_INCREF(Py_None);
return Py_None;
}
示例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
//.........这里部分代码省略.........