home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Languages / Python / python-14-src / PC / import_nt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-17  |  1.1 KB  |  40 lines

  1. /********************************************************************
  2.  
  3.  import_nt.c 
  4.  
  5.   Win32 specific import code.
  6.  
  7. */
  8.  
  9. #include "allobjects.h"
  10. #include "osdefs.h"
  11. #include <windows.h>
  12. #include "importdl.h"
  13.  
  14. extern BOOL PyWin_IsWin32s();
  15.  
  16. FILE *PyWin_FindRegisteredModule( const char *moduleName, struct filedescr **ppFileDesc, char *pathBuf, int pathLen)
  17. {
  18.     char moduleKey[128];
  19.     struct filedescr *fdp = NULL;
  20.     FILE *fp;
  21.     int modNameSize = pathLen;
  22.     HKEY keyBase = PyWin_IsWin32s() ? HKEY_CLASSES_ROOT : HKEY_LOCAL_MACHINE;
  23.     strcpy(moduleKey, "Software\\Python\\PythonCore\\" MS_DLL_ID "\\Modules\\");
  24.     strcat(moduleKey, moduleName);
  25.     if (RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize)!=ERROR_SUCCESS)
  26.         return NULL;
  27.     // use the file extension to locate the type entry.
  28.     for (fdp = import_filetab; fdp->suffix != NULL; fdp++) {
  29.         int extLen=strlen(fdp->suffix);
  30.         if (modNameSize>extLen && strnicmp(pathBuf+(modNameSize-extLen-1),fdp->suffix,extLen)==0)
  31.             break;
  32.     }
  33.     if (fdp->suffix==NULL)
  34.         return NULL;
  35.     fp = fopen(pathBuf, fdp->mode);
  36.     if (fp != NULL)
  37.         *ppFileDesc = fdp;
  38.     return fp;
  39. }
  40.