//---------------------------------------------------------------------------
#include <vcl.h>
#include <winuser.h>

#pragma hdrstop
USERES("DataViewer.res");
USEFORM("DViewer.cpp", DViewerF);
USEFORM("DViewer_Print.cpp", QuickReport1); /* TQuickRep: File Type */
USEFORM("DViewer_PrintHistoric.cpp", QRHistoric);
USEFORM("DViewer_PrintBonos.cpp", QRBonos);
USEFORM("DViewer_PrintClientes.cpp", QRClt);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE hPrevInstance, LPSTR, int)
{
  AnsiString FsMutex = DateToStr(TDateTime::CurrentDate()) + AnsiString("-mutex-dataviewer");
  HANDLE FhMutex = OpenMutex(MUTEX_ALL_ACCESS,False, FsMutex.c_str() );
  if ( FhMutex == 0 ) //it's a first instance
  {
    FhMutex = CreateMutex(NULL,false, FsMutex.c_str() );

    try
    {
        Application->Initialize();
        Application->Title = "Visualizador de Datos";
        Application->CreateForm(__classid(TDViewerF), &DViewerF);
                 Application->Run();
    }
    catch (Exception &exception)
    {
        Application->ShowException(&exception);
    }

  } else {
    if ( CloseHandle(FhMutex) ) FhMutex = 0;
  }
    return 0;
}
//---------------------------------------------------------------------------
