home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / pserv.cpl / pserv-2.4.exe / source / 2kwrapper.cpp next >
C/C++ Source or Header  |  2005-01-05  |  2KB  |  44 lines

  1. #include "stdafx.h"
  2. #include "2kwrapper.h"
  3.  
  4. // wrapper for functions available only unter 2k/xp
  5. LPFNQueryServiceStatusEx lpfnQueryServiceStatusEx = NULL;
  6. LPFNQueryServiceConfig2 lpfnQueryServiceConfig2 = NULL;
  7. LPFNEnumServicesStatusEx lpfnEnumServicesStatusEx = NULL;
  8. LPFNChangeServiceConfig2 lpfnChangeServiceConfig2 = NULL;
  9. LPFNGetLongPathName lpfnGetLongPathName = NULL;
  10.  
  11. class LoadMeAlways    
  12.     {
  13.     public:
  14.         LoadMeAlways()
  15.         {
  16.             HMODULE hModule = LoadLibrary(TEXT("advapi32.dll"));
  17.             if( hModule )
  18.             {
  19.                 lpfnQueryServiceStatusEx = (LPFNQueryServiceStatusEx) GetProcAddress(hModule, "QueryServiceStatusEx");
  20.                 #ifdef UNICODE
  21.                 lpfnQueryServiceConfig2 = (LPFNQueryServiceConfig2) GetProcAddress(hModule, "QueryServiceConfig2W");    
  22.                 lpfnEnumServicesStatusEx = (LPFNEnumServicesStatusEx) GetProcAddress(hModule, "EnumServicesStatusExW");
  23.                 lpfnChangeServiceConfig2 = (LPFNChangeServiceConfig2) GetProcAddress(hModule, "ChangeServiceConfig2W");    
  24.                 #else
  25.                 lpfnQueryServiceConfig2 = (LPFNQueryServiceConfig2) GetProcAddress(hModule, "QueryServiceConfig2A");    
  26.                 lpfnEnumServicesStatusEx = (LPFNEnumServicesStatusEx) GetProcAddress(hModule, "EnumServicesStatusExA");
  27.                 lpfnChangeServiceConfig2 = (LPFNChangeServiceConfig2) GetProcAddress(hModule, "ChangeServiceConfig2A");
  28.                 #endif
  29.             }
  30.             
  31.             hModule = LoadLibrary(TEXT("kernel32.dll"));
  32.             if( hModule )
  33.             {
  34.                 #ifdef UNICODE
  35.                 lpfnGetLongPathName = (LPFNGetLongPathName) GetProcAddress(hModule, "GetLongPathNameW");
  36.                 #else
  37.                 lpfnGetLongPathName = (LPFNGetLongPathName) GetProcAddress(hModule, "GetLongPathNameA");
  38.                 #endif
  39.             }
  40.         }
  41.     };
  42.  
  43. LoadMeAlways instance;
  44.