Хелпикс

Главная

Контакты

Случайная статья





dwTemp=105



B.

DWORD FuncExm (void)

{ DWORD dwTemp = 0;(1)

...........................

__try 

{

WaitForSingleObject (g_hSem, INFINITE) ;(2)

g_dwProtectedData = 5 ;(3)

dwTemp = g_dwProtectedData ;(4)

return (dwTemp);

}

__finally

{

dwTemp = g_dwProtectedData + 100 ;(5)         

ReleaseSemaphore (g_hSem, 1, NULL) ;(6)

return (dwTemp) ;(7){105}

}

dwTemp = 100 ;

return (dwTemp);

}

dwTemp=105

C.

void ExceptFun (void)

{ int x = 0;(1)

char * lpBuffer = NULL ;

__try {

* lpBuffer = ‘A’;(3)(10)// char s=’A’; lpBuffer=&s; ERROR

x = 100 / x ;

}

__except (ExceptFilter(&lpBuffer)(4))(9)(10)

{MessageBox(NULL, “An Exception occurred”, NULL, MB_OK)(14);}

MessageBox(NULL, “Function completed”, NULL, MB_OK)(15);

}

LONG ExceptFilter (char **lplpBuffer)(5)(11)

{ if (* lplpBuffer == NULL)(6)(12)

{ *lplpBuffer = g_szBuffer ;(7) // Global buffer pointer

return (EXCEPTION_CONTINUE_EXECUTION) ;(8)

}

return (EXCEPTION_EXECUTE_HANDLER)(13) ;

}

Out=” An Exception occurred Function completed”


D.

int ExceptFilter2 (char **lplpBuffer)(4)

{

  if (* lplpBuffer == NULL)(5)

  {     

        * lplpBuffer = g_szBuffer ;(6) // Global buffer pointer

  }

  return (EXCEPTION_EXECUTE_HANDLER) ;(7)

}

 

void ExceptFun2 (void)

{     

  int x = 0;(1)

  char * lpBuffer = NULL ;

  __try

  {

        * lpBuffer = 'A' ;(2)// char s=’A’; lpBuffer=&s; ERROR

        x = 100 / x ;

  }

  __except (ExceptFilter2(&lpBuffer)(3))

  {

        MessageBox(NULL, “An Exception occurred”, NULL, MB_OK)(8) ;

  }

MessageBox(NULL, “Function completed”, NULL, MB_OK)(9);

}

Out=”An Exception occurred Function completed



  

© helpiks.su При использовании или копировании материалов прямая ссылка на сайт обязательна.