1 Reply Latest reply on Nov 8, 2016 9:11 AM by Simone Padovan

    Start a SolidWorks session in background - silent mode - using C++

    Ioan Bordei

      Hello!

      From an .exe I want to start a new SolidWorks process in background.

      I try CreateProcess and ShellExecute as below but all the time SolidWorks start-up screen appears, if another session of SolidWorks already is running the journal warning is generated and the main window is display. I try to avoid all these, in that way all the process to be complete silent from the user side.

       

      STARTUPINFO StartupInfo;

      PROCESS_INFORMATION ProcessInfo;

      memset(&StartupInfo, 0, sizeof(StartupInfo));

      StartupInfo.cb = sizeof(STARTUPINFO);

      StartupInfo.dwFlags = STARTF_USESHOWWINDOW;

      StartupInfo.wShowWindow = SW_HIDE;

      if (::CreateProcess(L"C:\\Program Files\\SolidWorks Corp\\SolidWorks\\SLDWORKS.exe", L" /s", NULL, NULL, FALSE,CREATE_NO_WINDOW | CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &StartupInfo, &ProcessInfo))

      {

           WaitForSingleObject(ProcessInfo.hProcess, INFINITE);

           CloseHandle(ProcessInfo.hProcess);

           CloseHandle(ProcessInfo.hThread);

      }

      or

      ::ShellExecute(NULL, L"open", L"C:\\Program Files\\SolidWorks Corp\\SolidWorks\\SLDWORKS.exe", NULL,NULL,SW_HIDE);

       

      Using COM CoCreateInstance is not an option, because the newly created SolidWorks session must be complete with all add-ins loaded and activated, as a normal SolidWorks session. Also using C++ is critical.

      Any ideas are welcome!