Exit Rhino from C++ code/function unavailable?

I have a need to exit the Rhino process from a C++ plug-in, but when I call


in my code, the linker complains with

My question is: can I exit Rhino from C++ code, and if so, how?

RunScript with "_Exit"?

No, I mean unconditional exit - user should not be able to press “Cancel”.

I’ve solved it by using a callback function pointer to .NET code, where I can call RhinoApp.Exit(). Plus it is easier in .NET to show the user some dialogs & ask them to save their work before the exit.

Hi @menno,

CRhinoApp::ExitRhino() is not a publicly exported function, thus the unresolved external symbol error.

You might try one of these:


public class QuitCommand : Command
  public override string EnglishName => "Quit";

  protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    doc.Modified = false;
    PostMessage(RhinoApp.MainWindowHandle(), 0x0010 /*WM_CLOSE*/, 0, 0);
    return Result.Success;

  private static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);


CRhinoCommand::result CCommandQuit::RunCommand(const CRhinoCommandContext& context)
  ::PostMessage(RhinoApp().MainWnd(), WM_CLOSE, 0L, 0L);
  return CRhinoCommand::success;

– Dale

1 Like