zoukankan      html  css  js  c++  java
  • 获取当前插件路径

    CString CConfigDlg::GetModulePath()
    {
        TCHAR szPath[MAX_PATH] = { 0 };
        HMODULE hModule = NULL;
        GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
            (LPCSTR)"dsada", //可以是任何函数,全局变量等的地址 这里参考了 wr960204(武稀松)的专栏
            &hModule);
    
        if (GetModuleFileName(hModule,szPath,MAX_PATH))    //绝对路径。若第一个参数为NULL,返回程序所在PATH
        {
            PathRemoveFileSpec(szPath);        //除去了文件名字,只留下该项目生成DLL文件所在的路径名
        //    MessageBox(szPath);
        }
        else
        {
            AfxMessageBox("插件不存在");
        }
        CString strPath = szPath;
        return strPath;
    
        //原来的方法
        //    CHAR szModuleFileName[MAX_PATH] = { 0 };    //MAX_PATH 260
        //    GetModuleFileName( AfxGetApp()->m_hInstance, szModuleFileName, 260 );
        //    AfxMessageBox(szModuleFileName);
        //    CString strModulePath = szModuleFileName;
        //    int nPos = strModulePath.ReverseFind( TEXT('\\'));
        //    strModulePath = strModulePath.Left( nPos);
        //    return strModulePath;
    }
  • 相关阅读:
    面向对象进阶
    20191011作业
    2019.10.10作业
    类的继承
    面向对象
    2019.10.09作业
    pandas模块
    [BZOJ 2190][SDOI2008]仪仗队(欧拉函数)
    [BZOJ 2729][HNOI2012]排队(组合数学+高精)
    [BZOJ 1491][NOI2007]社交网络(Floyd)
  • 原文地址:https://www.cnblogs.com/zzugyl/p/2829235.html
Copyright © 2011-2022 走看看