获取exe或dll所在的路径

#include <direct.h>
#include <Windows.h>
#include <boost/filesystem.hpp>
#include <stdio.h>
 //获取exe或dll所在的路径
    wchar_t defaultPath[MAX_PATH];
    GetModuleFileName(NULL, defaultPath, MAX_PATH);
    std::wcout << defaultPath << std::endl;
    boost::filesystem::path programPath(defaultPath);
    std::string dir=programPath.parent_path().string();