【NX二次开发】获取UG安装路径
获取UG安装目录
1 string getNXPath()//D:\Program Files\Siemens\NX 12.0 2 { 3 TCHAR szFilePath[MAX_PATH + 1] = { 0 }; 4 GetModuleFileName(NULL, szFilePath, MAX_PATH); 5 CString str_url = szFilePath; 6 char chFilePath[100]; 7 CString2Char(str_url, chFilePath); 8 string strA = chFilePath; //路径为:D:\Program Files\Siemens\NX 12.0\NXBIN\ugraf.exe 9 string strSiemens("\\NX 12.0\\"); 10 int iA = strA.rfind(strSiemens); 11 string strB = strA.substr(0, iA + strSiemens.size()); // 路径为:D:\Program Files\Siemens\NX 12.0\ OK 12 return strB; 13 }