1
//============================================================================
3
// SSSS tt lll lll XX XX
4
// SS SS tt ll ll XX XX
5
// SS tttttt eeee ll ll aaaa XX XX
6
// SSSS tt ee ee ll ll aa XXX
7
// SS tt eeeeee ll ll aaaaa XX XX
8
// SS SS tt ee ll ll aa aa XX XX
9
// SSSS ttt eeeee llll llll aaaaa XX XX
11
// Copyright (c) 1995-2000 by Jeff Miller
12
// Copyright (c) 2004 by Stephen Anthony
14
// See the file "license" for information on usage and redistribution of
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
17
// $Id: main.cxx,v 1.3 2004/07/15 03:03:27 stephena Exp $
18
//============================================================================
23
#include "GlobalData.hxx"
24
#include "MainDlg.hxx"
29
CSingleInstance( LPCTSTR pszName )
31
::SetLastError( ERROR_SUCCESS );
32
m_hMutex = ::CreateMutex( NULL, TRUE, pszName );
33
m_dwError = ::GetLastError();
38
if ( m_hMutex != INVALID_HANDLE_VALUE && m_dwError != ERROR_ALREADY_EXISTS )
40
VERIFY( ::ReleaseMutex( m_hMutex ) );
41
VERIFY( ::CloseHandle( m_hMutex ) );
45
BOOL AlreadyExists( void ) const
47
return ( m_dwError == ERROR_ALREADY_EXISTS );
54
CSingleInstance( const CSingleInstance& ); // no implementation
55
void operator=( const CSingleInstance& ); // no implementation
58
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59
LPCTSTR g_ctszDebugLog = _T("stella.log");
61
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
62
int WINAPI _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
63
LPTSTR lpCmdLine, int nCmdShow )
65
UNUSED_ALWAYS( hPrevInstance );
66
UNUSED_ALWAYS( lpCmdLine );
67
UNUSED_ALWAYS( nCmdShow );
69
(void)::DeleteFile(g_ctszDebugLog);
71
CSingleInstance mutex( _T("StellaXMutex") );
72
if ( mutex.AlreadyExists() )
74
MessageBox( hInstance, NULL, IDS_ALREADYRUNNING );
78
HRESULT hrCoInit = ::CoInitialize( NULL );
79
if ( FAILED(hrCoInit) )
80
MessageBox( hInstance, NULL, IDS_COINIT_FAILED );
82
::InitCommonControls();
84
CGlobalData globaldata( hInstance );
87
MainDlg dlg( globaldata, hInstance );
90
if ( hrCoInit == S_OK )