Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->Title = "My Program";
Application->CreateForm(__classid(TMyProgForm), &MyProgForm);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
HANDLE MyProgmtx; // Add this with whatever name you want. You could just use "Mutex" if you wanted.
try
{
// Add the following code so only one instance of this program can be run
// Step One -- Open a mutex with the same name
MyProgmtx = OpenMutex (MUTEX_ALL_ACCESS, false, "MyProg");
// For the string above, I make certain that it is unigue
// For this reason, I use the program name
// Step Two -- Check to see if the mutex exists
if (CLMmtx == NULL)
CLMmtx = CreateMutex (NULL, true, "MyProg"); // If not, create it
else // If it does, display a warning and stop
{
ShowMessage("MyProg is already running!");
return 0;
}
// Add the above code
Application->Initialize();
Application->Title = "My Program";
Application->CreateForm(__classid(TMyProgForm), &MyProgForm);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
ReleaseMutex(MyProgmtx); // Add this line, too!
//Just make certain to use the same name as above
return 0;
}