Altova XMLSpy 2024 Professional Edition

In den nachstehenden Codefragmenten wurden den Schaltflächen im Beispiel AutomateXMLSpy die Methoden StartXMLSpy_Click und ShutdownXMLSpy_Click zugewiesen. Sie starten bzw. beenden die Applikation. Dieses Beispiel befindet sich im Unterordner C# des Ordners API Examples (siehe Datei Form1.cs):

 

 

Windows 7, Windows 8, Windows 10, Windows 11

C:\Benutzer\<Benutzername>\Dokumente\
Altova\XMLSpy\2024\Examples

 

Sie können das Projekt von Visual Studio 2012/2013/2015/2017/2019/2022 aus kompilieren und ausführen.

 

Starten von XMLSpy

Im folgenden Codefragment aus dem Beispiel AutomateXMLSpy wird gezeigt, wie man die Applikation startet.

 

  // Handler for the "Start XMLSpy" button

       private void StartXMLSpy_Click(object sender, EventArgs e)

       {

           if (XMLSpy == null)

           {

               Cursor.Current = Cursors.WaitCursor;

 

               // If no XMLSpy instance is running, we create one and make it visible

               XMLSpy = new XMLSpyLib.Application();

               XMLSpy.Visible = true;

 

               Cursor.Current = Cursors.Default;

           }

           else

           {

               // If an instance of XMLSpy is already running, make sure it's visible

               if (!XMLSpy.Visible)

                   XMLSpy.Visible = true;

           }

       }

 

 

Beenden von XMLSpy

Im folgenden Codefragment aus dem Beispiel AutomateXMLSpy wird gezeigt, wie man die Applikation beendet.

 

 // Handler for the "Shutdown XMLSpy" button

      // Shut down the application instance by explicitly releasing the COM object

       private void shutdownXMLSpy_Click(object sender, EventArgs e)

       {

           if (XMLSpy != null)

           {

               // Allow shutdown of XMLSpy by releasing the UI

               XMLSpy.Visible = false;

 

               // Explicitly release COM object

               try

               {

                   while (System.Runtime.InteropServices.Marshal.ReleaseComObject(XMLSpy) > 0) ;

               }

               finally

               {

                   // Disallow subsequent access to this object

                   XMLSpy = null;

               }

           }

       }

© 2017-2023 Altova GmbH