Whilst your application will be multi threaded if you hold waiting for something you need to use this to allow other tasks on the same thread to execute, and to tell the OS that your holding so it’s OK for it to attend to other things.


Remember that using this can potentially cause the same function that is using it to be re-called if whatever triggered it to be called happens again. You may need to use some sort of semaphore to protect against this.

Debug Mode Only Compiler Check

#if _DEBUG			//Only do if we're in debug mode

#if !_DEBUG			//Only do if we're in release mode

#if defined(_DEBUG) && defined(DEBUG_AUTO_LOG_IN_USER_ID)

Exiting The Application (i.e. File > Exit menu item)


Note that the Form..::.Closed and Form..::.Closing events are not raised when the Application..::.Exit method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the Form..::.Close method for each open form individually before calling the Exit method.
Or just use this instead:


Preventing Multiple Instances Of An Application Running

Place this in the YourApName.cpp file before Application::Run is called. It needs to be here as if you do it in the main forms constructor the application won’t exit correctly. You should only do it there if you change the Application::Exit to something else.

Process ^CurrentProcess = System::Diagnostics::Process::GetCurrentProcess();
array ^CurrentProcesses = System::Diagnostics::Process::GetProcessesByName(CurrentProcess->ProcessName);
if (CurrentProcesses->Length > 1)
	MessageBox::Show(L"There is already another instance of the application running", Application::ProductName, MessageBoxButtons::OK, MessageBoxIcon::Asterisk);
	return 0;

Get Windows Version

Use the GetVersionEx function

We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.