zoukankan      html  css  js  c++  java
  • NX二次开发获取当前DLL路径函数

    string GetPath();//输出程序路径
    string YiNingToolPath(string DLLDir); //分割程序路径获取工具目录


    HMODULE GetSelfModuleHandle() //获取运行程序的路径
    {

    MEMORY_BASIC_INFORMATION mbi;
    return ((::VirtualQuery(GetSelfModuleHandle, &mbi, sizeof(mbi)) != 0)
    ? (HMODULE)mbi.AllocationBase : NULL);
    }
    CString GetProgramDir() //获取运行程序的路径
    {
    char exeFullPath[MAX_PATH]; // 全路径
    string strPath = "";
    GetModuleFileName(GetSelfModuleHandle(), exeFullPath, MAX_PATH);
    strPath = (string)exeFullPath; // 获取程序路径
    int pos = strPath.find_last_of('\', strPath.length());
    CString path;
    path = strPath.substr(0, pos).c_str();
    return path;
    }

    string YN_BOM::GetPath() //输出程序路径
    {
    CString exe_path = GetProgramDir();
    string ProgramDirPath = exe_path;

    return string(ProgramDirPath);//返回路径
    }

    string YN_BOM::YiNingToolPath(string DLLDir) //分割程序路径获取工具目录
    {
    try
    {
    //反向找位置,分割字符串(只读取文件夹路径)
    string strPath = DLLDir;
    string strDir;
    int nPos = strPath.find_last_of('\');
    if (string::npos != nPos)
    {
    strDir = strPath.substr(0, nPos - 11);
    }

    return string(strDir);//返回文件夹路径
    }
    catch (exception& ex)
    {
    //---- Enter your exception handling code here -----
    YN_BOM::theUI->NXMessageBox()->Show("分割程序路径获取工具目录", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }


    }

    怡宁塑胶模具设计
  • 相关阅读:
    Rmarkdown:输出html设置
    Rmarkdown:输出pdf设置
    R语言绘图:雷达图
    R语言学习笔记(十五):获取文件和目录信息
    R语言学习笔记(十四):零碎知识点(41-45)
    R语言学习笔记(十三):零碎知识点(36-40)
    JVM调优-关于jvm的一些基本概念
    Markdown常用基本语法
    redis在windows中的安装
    jvm中加载类的全过程
  • 原文地址:https://www.cnblogs.com/hqsalanhuang/p/14993897.html
Copyright © 2011-2022 走看看