forked from Karasiq/MPQ-Repacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MPQRepacker.cpp
56 lines (55 loc) · 1.57 KB
/
MPQRepacker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#pragma once
#include <tchar.h>
//---------------------------------------------------------------------------
USEFORM("UPluginForm.cpp", frmPlugins);
USEFORM("USettingsForm.cpp", frmSettings);
USEFORM("UMainForm.cpp", MainForm);
//---------------------------------------------------------------------------
WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
try
{
HANDLE hMutex = OpenMutex( MUTEX_ALL_ACCESS, 0, "MPQ_REPACKER");
if(!hMutex)
{
hMutex = CreateMutex(0, 0, "MPQ_REPACKER");
}
else
{
HWND hWnd = FindWindow( 0, "MPQ RePacker v1.2 by ZxZ666");
if (hWnd) {SetForegroundWindow(hWnd);return 0;}
ExitProcess(0);
return 0;
}
// Unpack StormLib.dll from resources:
UnicodeString StormLibPath = GetTempDir() + "StormLib.dll";
if(ResUnpack("StormLib", StormLibPath)) LoadLibrary(StormLibPath.t_str());
Application->Initialize();
Application->MainFormOnTaskBar = true;
Application->CreateForm(__classid(TMainForm), &MainForm);
Application->CreateForm(__classid(TfrmPlugins), &frmPlugins);
Application->Run();
ReleaseMutex(hMutex);
ExitProcess(0); // Otherwise, for some reason, it remains hanging in the list of processes
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------