#include "system_class.h"
#include "macro.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
{
	system_class* System;
	bool result;
	
	wchar_t path[MAX_PATH];
	HMODULE hmodule = GetModuleHandle(NULL);
	if (hmodule != NULL)
	{
		GetModuleFileName(hmodule, path, (sizeof(path) / sizeof(wchar_t)));
	}
	
	std::filesystem::path exePath(path);
	std::filesystem::path WFolder = exePath.parent_path();
	
	// Create the system object.
	System = new system_class;
	
	// initialize and run the system object.
	result = System->initialize();
	if (result)
	{
		LOG_INIT("System initialized");
		System->send_path(path,WFolder);
		System->run();
	}
	
	// shutdown and release the system object.
	System->shutdown();
	delete System;
	System = 0;

	return 0;
}