Hello,
is there a way to get the path of the running AutoCAD executable without using COM (I'm not allowed to have a link to the Type Library). I don't want to believe that there is no string property with the executable.
way 1:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location);
way 2:
using System;
using System.Diagnostics;
using Autodesk.AutoCAD.ApplicationServices;
namespace AcadApp
{
public static string GetAcadExec()
{
IntPtr AcadPtr = Application.MainWindow.Handle;
Process[] arrProcs = Process.GetProcesses();
Process oProc = null;
string strPath = null;
foreach (Process p in arrProcs)
{
IntPtr nHandle = IntPtr.Zero;
try
{
nHandle = p.MainWindowHandle;
}
catch
{ }
if (nHandle != IntPtr.Zero && nHandle == AcadPtr)
{
oProc = p;
break;
}
}
if (oProc != null)
strPath = System.IO.Path.GetDirectoryName(oProc.MainModule.FileName);
return strPath;
}
}
Isn't there any property to ask for the path of acad.exe?
Thanks, Fred