Subversion Repositories spk

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
// SpkExplorer.cpp : main project file.
2
 
3
#include "stdafx.h"
4
#include "Forms/Form1.h"
5
 
6
#undef GetTempPath
7
 
8
using namespace SpkExplorer;
9
using namespace System;
10
using namespace System::IO;
11
 
12
 
13
[STAThreadAttribute]
14
int main(array<System::String ^> ^args)
15
{
16
	// Enabling Windows XP visual effects before any controls are created
17
	Application::EnableVisualStyles();
18
	Application::SetCompatibleTextRenderingDefault(false); 
19
 
20
	System::String ^temp = IO::Path::GetTempPath();
21
 
22
	bool firstInstance = false;
23
	System::Threading::Mutex ^mut = gcnew System::Threading::Mutex(false, "Local\\XSpkExplorer", firstInstance);
24
	if ( !firstInstance )
25
	{
26
		if ( args->Length )
27
		{
28
			if ( File::Exists(temp + "\\spkexplorer_load.dat") )
29
			{
30
				StreamWriter ^sw = File::AppendText(temp + "\\spkexplorer_load.dat");
31
				try 
32
				{
33
					for ( int i = 0; i < args->Length; i++ )
34
						sw->WriteLine("File: " + args[i]);
35
				}
36
				finally
37
				{
38
					if ( sw )
39
						delete (IDisposable ^)sw;
40
				}
41
			}
42
			else
43
			{
44
				StreamWriter ^sw = File::CreateText(temp + "\\spkexplorer_load.dat");
45
				try 
46
				{
47
					for ( int i = 0; i < args->Length; i++ )
48
						sw->WriteLine("File: " + args[i]);
49
				}
50
				finally
51
				{
52
					if ( sw )
53
						delete (IDisposable ^)sw;
54
				}
55
			}
56
 
57
			return 0;
58
		}
59
		else
60
		{
61
			MessageBox::Show("There is already another instance of the SPK Explorer Running", "Already Running", MessageBoxButtons::OK, MessageBoxIcon::Error);
62
			return 1;
63
		}
64
	}
65
 
66
	if ( File::Exists(temp + "\\spkexplorer_load.dat") )
67
	{
68
		try { File::Delete(temp + "\\spkexplorer_load.dat"); }
69
		catch (System::IO::IOException ^) {}
70
		catch (System::Exception ^) {}
71
	}
72
 
73
 
74
	// Create the main window and run it
75
	Application::Run(gcnew Form1(args));
76
	return 0;
77
}