DIV
EOF
Ler
Expandir Minimizar
Este tópico ainda não foi avaliado como - Avalie este tópico

_CrtSetReportHook2, _CrtSetReportHookW2

Installs or uninstalls a função Reporting Client-defined by hooking IT into the executar C-tempo Depurar Reporting processo (Depurar versão Only).


int _CrtSetReportHook2(
   int mode,
   _CRT_REPORT_HOOK pfnNewHook
);
int _CrtSetReportHookW2(
   int mode,
   _CRT_REPORT_HOOKW pfnNewHook
);
mode

A ação a ser executada: _CRT_RPTHOOK_INSTALL ou _CRT_RPTHOOK_REMOVE.

pfnNewHook

Relatar gancho to instalar or remover in the estreito-versão caractere of this função.

pfnNewHook

Relatar gancho to instalar or remover in the wide-character version of this função.

-1 se um erro foi encontrado, com EINVAL ou ENOMEM conjunto; returns the reference Contar of pfnNewHook after the .

_CrtSetReportHook2 e _CrtSetReportHookW2 permitem que você conectar ou desprender uma função, enquanto _CrtSetReportHook somente permite que você conectar uma função.

_CrtSetReportHook2 or _CrtSetReportHookW2 should be used INSTEAD OF _CrtSetReportHook when the chamar gancho is made in a DLL and when múltiplo DLLs Might be Carregado and configuração their own funções gancho.In such a situation, DLLs can be unloaded in a ordem different than they were Loaded and the função gancho can be Esquerda Pointing at an DLL unloaded.Any saída depuração crashes the processo If the funções gancho were Adicionado with _CrtSetReportHook.

Any funções gancho Adicionado with _CrtSetReportHook are chamado if there não are funções gancho Adicionado with _CrtSetReportHook2 or _CrtSetReportHookW2 or if funções gancho all Adicionado with _CrtSetReportHook2 and _CrtSetReportHookW2 Return FALSE.

A versão de caracteres longa desta função está disponível em O Visual C++ 2005.The funções gancho relatório Take a Cadeia de Caracteres whose tipo (wide or estreito Characters) must match the versão of this função used.Use the seguinte protótipo função for the Relatar hooks Used with the wide-character version of this função:

int YourReportHook( int reportType, wchar_t *message, int *returnValue );

Use the seguinte protótipo for the estreito-caractere Relatar hooks:

int YourReportHook( int reportType, char *message, int *returnValue );

These funções Validate their Parâmetros.Se mode ou pfnNewNook for inválido, essas funções chamam o manipulador de parâmetro inválido, conforme descrito em A validação de parâmetro.Se a execução for permitida para continuar, essas funções definido para errnoEINVAL e retornam-1.

ObservaçãoObservação:

If Your aplicativo is compilado with /clr and the Reporting função Is chamado after the aplicativo has Exited Main, the will CLR Gerar uma Exceção If the função Reporting Calls any funções CRT.

Rotina

Cabeçalho necessário

Cabeçalho opcional

Compatibility

_CrtSetReportHook2

< crtdbg.h >

< errno.h >

Windows 95, Windows 98, segundo Edition Windows 98, Windows Millennium Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Servidor 2003

_CrtSetReportHookW2

< crtdbg.h >

< errno.h >

Windows 95, Windows 98, segundo Edition Windows 98, Windows Millennium Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Servidor 2003

Para obter mais informações de compatibilidade, consulte compatibilidade no Guia de Introdução.

Bibliotecas

Depurar versões C bibliotecas de tempo de execução somente.

// crt_setreporthook2.c
#include <windows.h>
#include <stdio.h>
#include <crtdbg.h>
#include <assert.h>

int __cdecl TestHook1(int nReportType, char* szMsg, int* pnRet)
{
   int nRet = FALSE;

   printf("CRT report hook 1.\n");
   printf("CRT report type is \"");
   switch (nReportType)
   {
      case _CRT_ASSERT:
      {
         printf("_CRT_ASSERT");
         // nRet = TRUE;   // Always stop for this type of report
         break;
      }

      case _CRT_WARN:
      {
         printf("_CRT_WARN");
         break;
      }

      case _CRT_ERROR:
      {
         printf("_CRT_ERROR");
         break;
      }

      default:
      {
         printf("???Unknown???");
         break;
      }
   }

   printf("\".\nCRT report message is:\n\t");
   printf(szMsg);

   if   (pnRet)
      *pnRet = 0;

   return   nRet;
}

int __cdecl   TestHook2(int nReportType, char* szMsg, int* pnRet)
{
   int   nRet = FALSE;

   printf("CRT report hook 2.\n");
   printf("CRT report type is \"");
   switch   (nReportType)
   {
      case _CRT_WARN:
      {
         printf("_CRT_WARN");
         break;
      }

      case _CRT_ERROR:
      {
         printf("_CRT_ERROR");
         break;
      }

      case _CRT_ASSERT:
      {
         printf("_CRT_ASSERT");
         nRet = TRUE;   // Always stop for this type of report
         break;
      }

      default:
      {
         printf("???Unknown???");
         break;
      }
   }

   printf("\".\nCRT report message is: \t");
   printf(szMsg);

   if   (pnRet)
      *pnRet = 0;
   // printf("CRT report code is %d.\n", *pnRet);
   return   nRet;
}

int   main(int argc, char* argv[])
{
   int   nRet = 0;

   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook1);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook1)"
          " returned %d\n", nRet);
   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook2);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook2)"
          " returned %d\n", nRet);
   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook2);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook2)"
          " returned %d\n", nRet);
   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook1);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook1)"
          " returned %d\n", nRet);
   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook1);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook1)"
          " returned %d\n", nRet);

   _ASSERT(0);

   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2)"
          " returned %d\n", nRet);
   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2)"
          " returned %d\n", nRet);
   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2)"
          " returned %d\n", nRet);
   nRet = _CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook1);
   printf("_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook1)"
          " returned %d\n", nRet);

   return   nRet;
}
_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook1) returned 0
_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook2) returned 0
_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook2) returned 0
_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook1) returned 0
_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestHook1) returned 0
_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2) returned 0
_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2) returned 0
_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook2) returned 0
_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestHook1) returned 0
Isso foi útil para você?
(1500 caracteres restantes)

Contribuições da comunidade

ADICIONAR
A Microsoft está realizando uma pesquisa online para saber sua opinião sobre o site do MSDN. Se você optar por participar, a pesquisa online lhe será apresentada quando você sair do site do MSDN.

Deseja participar?
© 2013 Microsoft. Todos os direitos reservados.