home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / CHAP6.ZIP / CHECKORD.C < prev    next >
Encoding:
Text File  |  1992-06-11  |  1.3 KB  |  45 lines

  1. /*
  2.     CHECKORD.C -- Checks that the function name exists in the
  3.     expected module at the expected ordinal number. Also sets
  4.     up a default window title.
  5.  
  6.     Used in example programs from
  7.     Chapters 6 & 8 of "Undocumented Windows" (Addison-Wesley 1992)
  8.     by Andrew Schulman, Dave Maxey and Matt Pietrek
  9.  
  10. */
  11.  
  12.  
  13. BOOL CheckOrdName(char *szFunction, char *szModule, int nOrdinal)
  14.     {
  15.     HANDLE hModule;
  16.     FARPROC lpfnByName;
  17.     FARPROC lpfnByOrd;
  18.     char achTitle[80];
  19.  
  20.     sprintf(achTitle, "%s() [%s.%d]", szFunction, szModule, nOrdinal);
  21.     winio_settitle(__hMainWnd, achTitle);
  22.     hModule = GetModuleHandle((LPSTR) szModule);
  23.     lpfnByName = GetProcAddress(hModule, (LPSTR) szFunction);
  24.     lpfnByOrd = GetProcAddress(hModule, (LPSTR) ((DWORD) nOrdinal));
  25.     printf("hModule = %04X, by name = %Fp, by ord = %Fp\n\n",
  26.             hModule, lpfnByName, lpfnByOrd);
  27.     if (hModule == NULL)
  28.         printf("Module %s not loaded !!!\nAborting\n", szModule);
  29.     else
  30.     if (lpfnByName == NULL)
  31.         printf("Function %s not found in module %s !!!\n"
  32.             "Aborting\n", szFunction, szModule);
  33.     else
  34.     if (lpfnByOrd == NULL)
  35.         printf("Ordinal %d not found in module %s !!!\n"
  36.             "Aborting\n", nOrdinal, szModule);
  37.     else
  38.     if (lpfnByName != lpfnByOrd)
  39.         printf("Function %s not found at ordinal %d !!!\n"
  40.             "Aborting\n", szFunction, nOrdinal);
  41.     else
  42.         return TRUE;
  43.     
  44.     return FALSE;
  45.     }