home *** CD-ROM | disk | FTP | other *** search
- /*
- CHECKORD.C -- Checks that the function name exists in the
- expected module at the expected ordinal number. Also sets
- up a default window title.
-
- Used in example programs from
- Chapters 6 & 8 of "Undocumented Windows" (Addison-Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- */
-
-
- BOOL CheckOrdName(char *szFunction, char *szModule, int nOrdinal)
- {
- HANDLE hModule;
- FARPROC lpfnByName;
- FARPROC lpfnByOrd;
- char achTitle[80];
-
- sprintf(achTitle, "%s() [%s.%d]", szFunction, szModule, nOrdinal);
- winio_settitle(__hMainWnd, achTitle);
- hModule = GetModuleHandle((LPSTR) szModule);
- lpfnByName = GetProcAddress(hModule, (LPSTR) szFunction);
- lpfnByOrd = GetProcAddress(hModule, (LPSTR) ((DWORD) nOrdinal));
- printf("hModule = %04X, by name = %Fp, by ord = %Fp\n\n",
- hModule, lpfnByName, lpfnByOrd);
- if (hModule == NULL)
- printf("Module %s not loaded !!!\nAborting\n", szModule);
- else
- if (lpfnByName == NULL)
- printf("Function %s not found in module %s !!!\n"
- "Aborting\n", szFunction, szModule);
- else
- if (lpfnByOrd == NULL)
- printf("Ordinal %d not found in module %s !!!\n"
- "Aborting\n", nOrdinal, szModule);
- else
- if (lpfnByName != lpfnByOrd)
- printf("Function %s not found at ordinal %d !!!\n"
- "Aborting\n", szFunction, nOrdinal);
- else
- return TRUE;
-
- return FALSE;
- }