Tony,
Thanks but this solution is much generic and I have to use the PSAPI on NT
based OS due the processes what will request a DLL distribution, version
problems, etc...too much complex for a simple routine!
As I'm looking for another AutoCAD instances from ARX maybe the ObjectARX
has something to do that or AutoCAD has a particular feature attached to its
window that allows to check if the CWnd pointer is pointing to an AutoCAD
window.
Regards,
Fernando.
"Tony Tanzillo" wrote in message
news:9B4DD946CCED5FA694E4A8D596BA3691@in.WebX.maYIadrTaRb...
> Well - it depends on what you're planning to do with multiple
> instances. There's not much you can do with the handle except
> send messages. Is that what this is for?
>
> In any case, you don't need to play guessing games with the
> window caption. If you use EnumWindows(), then you would just
> get the hInstance of the process that owns each window using
> GetWindowLong(..., GWL_HINSTANCE) then use GetModuleFileNameEx()
> to get the name the executable for the process that created
> the window, and see if it's "acad.exe".
>
> You can also search MSDN for GetWindowThreadProcessId and
> you'll find some code in a KB article that shows another
> way to do it (I believe there are different approaches for
> Win9X and NT based OSs).
>
> "Fernando Malard" wrote in message
> news:FFD12A89C843D30EF5CF15906B77E1FF@in.WebX.maYIadrTaRb...
> > Tony,
> >
> > Another approach could be the system api function ::GetDesktopWindow()
and
> > then traverse each child to know if it is an AutoCAD window.
> >
> > This could be very nice once you can send messages to each window that
> will
> > allow you to fire AutoCAD commands.
> >
> > The problem here is how to check if each window is AutoCAD kind.
> >
> > As I get a CWnd pointer for each traversed one I can compare it with
> > adsw_acadMainWnd() to know if I'm getting myself, but what about others?
> >
> > I will hate to get each Window's name and check if this name has a
> substring
> > called "AutoCAD - " that is what it shows on main dialog title. This
will
> > fail if this is another vertical product like Autodesk MAP...
> >
> > Could you point me another way to check if a CWnd is an AutoCAD kind
> window?
> >
> > Regards,
> > Fernando.
> >
> > "Tony Tanzillo" wrote in message
> > news:79110F8BA993F5992C3DE671FFFA05D3@in.WebX.maYIadrTaRb...
> > > Yes, it should.
> > >
> > > "Fernando Malard" wrote in message
> > > news:1D214D76AB591001EB1737B325A492E1@in.WebX.maYIadrTaRb...
> > > > Tony,
> > > >
> > > > This will work to AutoCAD R14?
> > > >
> > > > "Tony Tanzillo" wrote in message
> > > > news:5E3C366ABB14EE99DF54A0534913C737@in.WebX.maYIadrTaRb...
> > > > > You can iterate through the running object table to find
> > > > > the IDispatch interface of any AcadDocument that's open
> > > > > in every AutoCAD instance (excluding new/unnamed/unsaved
> > > > > drawings), and from each document, you can get a pointer
> > > > > to the Application object.
> > > > >
> > > > > See the IRunningObjectTable interface in MSDN.
> > > > >
> > > > > Or, you can enumerate all running processes using the
> > > > > ToolHelp API.
> > > > >
> > > > > "Fernando Malard" wrote in message
> > > > > news:234C0C1FE3B0E182E89FDC083EFDEF33@in.WebX.maYIadrTaRb...
> > > > > > Hello,
> > > > > >
> > > > > > How can I find out if there is another AutoCAD application
> instances
> > > > > running
> > > > > > ?
> > > > > >
> > > > > > Regards,
> > > > > > Fernando.
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>