P
Okay, habs selbst herausgefunden (zwangsläufig)...
Danke fürs "rege" Interesse ;))
Hier die Lösung:
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{ // Name der Anwendung im TASK Manager und Titelleiste
AnsiString AppTitle = "MyApp v1";
// bereits aktive Instanz in den Vordergrund holen
HWND hWin = FindWindow("TApplication", AppTitle.c_str());
SetForegroundWindow(hWin);
// doppelte Programminstanzen verhindern/beenden
HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS, 0, "MYAPP");
if(!hMutex)
{
hMutex = CreateMutex(0, 0, "MAAPP");
}
else
{
return 0;
}
// Programmstart
Application->Title = AppTitle;
Application->Initialize();
ReleaseMutex(hMutex);
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
Der Fehler lag darin, dass die Aufrufe
HWND hWin = FindWindow("TApplication", AppTitle.c_str());
SetForegroundWindow(hWin);
vor
Application->Title = AppTitle;
Application ....
....
stehen müssen. Weiss einer warum?