Blame | Last modification | View Log | RSS feed
// SpkExplorer.cpp : main project file.
#include "stdafx.h"
#include "Forms/Form1.h"
#undef GetTempPath
using namespace SpkExplorer;
using namespace System;
using namespace System::IO;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
System::String ^temp = IO::Path::GetTempPath();
bool firstInstance = false;
System::Threading::Mutex ^mut = gcnew System::Threading::Mutex(false, "Local\\XSpkExplorer", firstInstance);
if ( !firstInstance )
{
if ( args->Length )
{
if ( File::Exists(temp + "\\spkexplorer_load.dat") )
{
StreamWriter ^sw = File::AppendText(temp + "\\spkexplorer_load.dat");
try
{
for ( int i = 0; i < args->Length; i++ )
sw->WriteLine("File: " + args[i]);
}
finally
{
if ( sw )
delete (IDisposable ^)sw;
}
}
else
{
StreamWriter ^sw = File::CreateText(temp + "\\spkexplorer_load.dat");
try
{
for ( int i = 0; i < args->Length; i++ )
sw->WriteLine("File: " + args[i]);
}
finally
{
if ( sw )
delete (IDisposable ^)sw;
}
}
return 0;
}
else
{
MessageBox::Show("There is already another instance of the SPK Explorer Running", "Already Running", MessageBoxButtons::OK, MessageBoxIcon::Error);
return 1;
}
}
if ( File::Exists(temp + "\\spkexplorer_load.dat") )
{
try { File::Delete(temp + "\\spkexplorer_load.dat"); }
catch (System::IO::IOException ^) {}
catch (System::Exception ^) {}
}
// Create the main window and run it
Application::Run(gcnew Form1(args));
return 0;
}