SOL9 2.0 Class: ModuleLoader

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * ModuleLoader.h 
 * Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9


#pragma once

#include <sol/Object.h>
#include <sol/String.h>

namespace SOL {

class ModuleLoader :public Object {

private:
    HMODULE hModule;

public:
    ModuleLoader()
    :hModule(NULL)
    {

    }

public:
    ~ModuleLoader()
    {
        clear();
    }


public:

    bool load(__in const char* argv,
        __in DWORD dwFlags=LOAD_LIBRARY_AS_DATAFILE|LOAD_WITH_ALTERED_SEARCH_PATH)
    {    
        bool rc = false;
        clear();
    
        if ((hModule = LoadLibraryEx(argv, NULL, dwFlags) )) {
            rc = true;
        } else {
            rc = false;
        }
        return rc;
    }

public:

    bool load(__in const wchar_t* argv, 
        __in DWORD dwFlags=LOAD_LIBRARY_AS_DATAFILE|LOAD_WITH_ALTERED_SEARCH_PATH)
    {    
        bool rc = false;
        clear();
    
        if ((hModule = LoadLibraryExW(argv, NULL, dwFlags) )) {
            rc = true;
        } else {
            rc = false;
        }
        return rc;
    }

public:
    void clear()
    {
        if (hModule) {
            FreeLibrary(hModule);
            hModule = NULL;
        }        
    }

public:
    HMODULE getHModule() {
        return hModule;
    }
};

}



Last modified: 1 Feb 2012

Copyright (c) 2009-2012 Antillia.com ALL RIGHTS RESERVED.