请问一下获取DLL文件当前目录的方法

请教一下获取DLL文件当前目录的方法
各位大大好,请教一个问题。我要给甲方做一个DLL,供他调用。他的可执行文件在目录a中,把我的DLL放在目录b中。当我的DLL中的某个函数运行时,需要读取一个配置文件config.ini,这个ini文件和我的DLL文件同在目录b中。但是我不知道怎样获取目录b的路径(这个路径不一定,我无法知道绝对路径),也就无法打开ini文件。用GetModuleFileName()函数只能获取到他的可执行文件的路径,而无法获得我DLL的路径。

  请问有什么方法可以获得我DLL的路径吗?

------解决方案--------------------
C/C++ code


/****************************************************************************
使用下面的HMODULE GetCurrentModule()可以获取dll自己的句柄。
接着使用
TCHAR lib_name[MAX_PATH]; 
::GetModuleFileName( GetCurrentModule(), lib_name, MAX_PATH );
就可以获取dll的路径了

Most DLL developers have faced the challenge of detecting a HMODULE/HINSTANCE handle 
within the module you're running in. It may be a difficult task if you wrote the DLL 
without a DLLMain() function or you are unaware of its name. For example:
Your DLL was built without ATL/MFC, so the DLLMain() function exists, 
but it's hidden from you code and you cannot access the hinstDLL parameter. 
You do not know the DLL's real file name because it could be renamed by everyone, 
so GetModuleHandle() is not for you.
This small code can help you solve this problem:
****************************************************************************/
#if _MSC_VER >= 1300    // for VC 7.0
// from ATL 7.0 sources
#ifndef _delayimp_h
extern "C" IMAGE_DOS_HEADER __ImageBase;
#endif
#endif

static
HMODULE GetCurrentModule()
{
#if _MSC_VER < 1300    // earlier than .NET compiler (VC 6.0)
    
    // Here's a trick that will get you the handle of the module
    // you're running in without any a-priori knowledge:
    MEMORY_BASIC_INFORMATION mbi;
    static int dummy;
    VirtualQuery( &dummy, &mbi, sizeof(mbi) );
    
    return reinterpret_cast<HMODULE>(mbi.AllocationBase);
#else    // VC 7.0
    // from ATL 7.0 sources
    return reinterpret_cast<HMODULE>(&__ImageBase);
#endif
}