Click here to Skip to main content
15,883,969 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello! everyone!

AutoCAD::IAcadApplication *pAcad;
CLSID clsid;

HRESULT hr= ::CLSIDFromProgID(L"AutoCAD.Application", &clsid);
if (FAILED(hr))
return;
HRESULT res=::GetActiveObject(clsid, NULL, &pUnk);
if(res != S_OK)
  return;


It's AutoCAD program,Now I want to automate it by COM in my app.

Now the problem is GetActiveObject(clsid, NULL, &pUnk); I cann't get more control on it.
i.e
IF the user have several AutOCAD instances running . And How I can guarantee that always get the most newly created one?

And if my app startup the autocad by ShellExecuteEX then I can get the Hanlde of it.

By this Handle, May I get it's corresponding Com's object?

THANKS!
Posted

1 solution

First: For details about the AutoCad autimation you better consult some forums of the Autocad-community.

Second: Why havent you read the doc about ShellExecuteEX ???

http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).aspx[^]

There is a handle is a out parameter :mad:
 
Share this answer
 
Comments
KarstenK 24-Jun-13 2:14am    
My answer is "No" but maybe there is a way.

To run with COm objects you need to start with COM. Create an instance and make it run.

You better asks that questions in AutoCad forums or the product specific support. ;-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900