Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_UTIL_WIN32_CACHEDLL_H__
00021 #define __CS_UTIL_WIN32_CACHEDLL_H__
00022
00027 namespace CS
00028 {
00029 namespace Platform
00030 {
00031 namespace Win32
00032 {
00033
00046 class CacheDLL
00047 {
00048 const char* dllName;
00049 HMODULE dllHandle;
00050 public:
00051 CacheDLL (const char* dll) : dllName(dll), dllHandle (0)
00052 {
00053 }
00054
00055 ~CacheDLL ()
00056 {
00057 if (dllHandle != 0)
00058 FreeLibrary (dllHandle);
00059 }
00060
00061 HMODULE GetHandle ()
00062 {
00063 if (dllHandle == 0)
00064 dllHandle = LoadLibraryA (dllName);
00065 return dllHandle;
00066 }
00067
00068 operator HMODULE ()
00069 {
00070 return GetHandle ();
00071 }
00072 };
00073
00074 }
00075 }
00076 }
00077
00078 #endif // __CS_UTIL_WIN32_CACHEDLL_H__