Starten und Beenden der Applikation
In den nachstehenden Codefragmenten wurden den Schaltflächen im Beispiel AutomateAuthenticDesktop die Methoden StartAuthenticDesktop_Click und ShutdownAuthenticDesktop_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\Authentic2026\AuthenticExamples |
Sie können das Projekt von Visual Studio 2013, 2015, 2017, 2019, 2022, 2026 Insiders aus kompilieren und ausführen.
Starten von Authentic Desktop
Im folgenden Codefragment aus dem Beispiel AutomateAuthenticDesktop wird gezeigt, wie man die Applikation startet.
// Handler for the "Start AuthenticDesktop" button
private void StartAuthenticDesktop_Click(object sender, EventArgs e)
{
if (AuthenticDesktop == null)
{
Cursor.Current = Cursors.WaitCursor;
// If there is no AuthenticDesktop instance, create one and make it visible.
AuthenticDesktop = new XMLSpyLib.Application();
AuthenticDesktop.Visible = true;
Cursor.Current = Cursors.Default;
}
else
{
// If an instance of Authentic Desktop is already running, make sure it's visible
if (!AuthenticDesktop.Visible)
AuthenticDesktop.Visible = true;
}
}
Beenden von Authentic Desktop
Im folgenden Codefragment aus dem Beispiel AutomateAuthenticDesktop wird gezeigt, wie man die Applikation beendet.
// Handler for the "Shut down AuthenticDesktop" button
// Shut down application instance by explicitely releasing the COM object.
private void shutdownAuthenticDesktop_Click(object sender, EventArgs e)
{
if (AuthenticDesktop != null)
{
// Allow shut down of AuthenticDesktop by releasing the UI
AuthenticDesktop.Visible = false;
// Explicitly release the COM object
try
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(AuthenticDesktop) > 0) ;
}
finally
{
// Avoid subsequent access to this object.
AuthenticDesktop = null;
}
}
}