Partager via


IBackgroundCopyJob ::SetNotifyInterface, méthode (bits.h)

Identifie votre implémentation de l’interface IBackgroundCopyCallback sur BITS. Utilisez l’interface IBackgroundCopyCallback pour recevoir la notification des événements liés au travail.

Syntaxe

HRESULT SetNotifyInterface(
  IUnknown *Val
);

Paramètres

Val

Pointeur d’interface IBackgroundCopyCallback . Pour supprimer le pointeur actuel de l’interface de rappel, définissez ce paramètre sur NULL.

Valeur retournée

Cette méthode retourne les valeurs HRESULT suivantes, ainsi que d’autres.

Code de retour Descriptif
S_OK
Le pointeur de l’interface de notification a été correctement défini.
BG_E_INVALID_STATE
L’état du travail ne peut pas être BG_JOB_STATE_CANCELLED ou BG_JOB_STATE_ACKNOWLEDGED.

Remarques

Appelez cette méthode uniquement si vous implémentez l’interface IBackgroundCopyCallback . Utilisez la méthode SetNotifyInterface conjointement avec la méthode SetNotifyFlags pour spécifier le type de notification que vous souhaitez recevoir.

L’interface de notification devient non valide lorsque votre application se termine ; BITS ne conserve pas l’interface de notification. Par conséquent, le processus d’initialisation de votre application doit appeler la méthode SetNotifyInterface sur les travaux existants pour lesquels vous souhaitez recevoir une notification. Si vous devez capturer les informations d’état et de progression qui se sont produites depuis la dernière exécution de votre application, interrogez les informations d’état et de progression pendant l’initialisation de l’application.

Notez que BITS appelle votre rappel même si l’événement pour lequel vous avez déjà été inscrit s’est produit.

En guise d’alternative à la réception d’une notification de rappel, vous pouvez vous inscrire pour que BITS exécute une ligne de commande pour les événements d’erreur et transférés. Pour plus d’informations, consultez la méthode IBackgroundCopyJob2 ::SetNotifyCmdLine .

Notez que si plusieurs applications appellent la méthode SetNotifyInterface pour définir l’interface de notification du travail, la dernière application à appeler la méthode SetNotifyInterface est celle qui recevra des notifications , les autres applications ne recevront pas de notifications.

Examples

L’exemple suivant montre comment appeler la méthode SetNotifyInterface . Pour plus d’informations sur l’exemple de classe CNotifyInterface utilisé dans l’exemple suivant, consultez l’interface IBackgroundCopyCallback . L’exemple suppose que le pointeur d’interface IBackgroundCopyJob est valide.

IBackgroundCopyJob* pJob;
CNotifyInterface* pNotify = new CNotifyInterface();

hr = pJob->SetNotifyInterface(pNotify);
if (SUCCEEDED(hr))
{
  hr = pJob->SetNotifyFlags(BG_NOTIFY_JOB_TRANSFERRED | 
                            BG_NOTIFY_JOB_ERROR);
}
pNotify->Release();
pNofity = NULL;

if (FAILED(hr))
{
  //Handle error - unable to register for event notification.
}

Spécifications

Requirement Valeur
Client minimum requis Windows XP
Serveur minimal pris en charge Windows Server 2003
plateforme cible Fenêtres
Header bits.h
Library Bits.lib
DLL QmgrPrxy.dll

Voir aussi

IBackgroundCopyCallback

IBackgroundCopyJob2 ::SetNotifyCmdLine

IBackgroundCopyJob ::GetNotifyInterface

IBackgroundCopyJob ::SetNotifyFlags