What's new

Launching Alibre prior to excuting API (VC++2008 MFC)

wathavy4

Alibre Super User
When using MFC VC++2008, you could launch Alibre automatically with the following Windows API.

( The following is the contents of function LanchAlibre() )
Code:
    STARTUPINFO         siStartupInfo;
    PROCESS_INFORMATION piProcessInfo;

    memset(&siStartupInfo, 0, sizeof(siStartupInfo));
    memset(&piProcessInfo, 0, sizeof(piProcessInfo));

    siStartupInfo.cb = sizeof(siStartupInfo);

    if(CreateProcess("C:\\Program Files\\Alibre Design\\Program\\Alibre Design.exe",     // Application name
                     0,                 // Application arguments
                     0,
                     0,
                     FALSE,
                     CREATE_DEFAULT_ERROR_MODE,
                     0,
                     0,                              // Working directory
                     &siStartupInfo,
					 &piProcessInfo) == FALSE){
	}
	Sleep(3000);//Wait for Alibre to stabilize.
(Ref:http://www.codeguru.com/forum/showthread.php?t=302501)

I modified one of the example from VC++ named "GeometryAndTopologyQuery"
Ref: viewtopic.php?f=13&t=8186

I added try{} catch(){} at the top of ConnectToAlibre().
Code:
HRESULT CGeometryAndTopologyQueryDlg::ConnectToAlibre()
{
	HRESULT hr = E_UNEXPECTED;
	try
	{
		if(m_pRoot == NULL)
		{
			LaunchAlibre();
		}
	}
	catch(...)
	{
		AfxMessageBox ("Exception caught while lanuching Alibre!");
		return E_UNEXPECTED;
	}
	try
	{
		// If m_pRoot is not NULL that means application is already connected to Alibre and this 
	..
 

Attachments

  • GeometryAndTopologyQuery.7z
    41.4 KB · Views: 78

wathavy4

Alibre Super User
This is a dialog application which only lauch Alibre and initilize
IADRootPtr m_pRoot



To Nate; Yes to your latter query. :eek:
 

Attachments

  • V2011.7z
    69.1 KB · Views: 81
Top