code_junkie

Visual C++ GUI app stuck in MTA mode

Nov 13th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. [STAThreadAttribute]
  2. int main(array<System::String ^> ^args)
  3. {
  4. Application::EnableVisualStyles();
  5. Application::SetCompatibleTextRenderingDefault(false);
  6. Application::Run(gcnew Form1());
  7. return 0;
  8. }
  9.  
  10. int main(array<System::String ^> ^args)
  11. {
  12.  
  13. System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
  14. if (Thread::CurrentThread->GetApartmentState() != ApartmentState::STA)
  15. {
  16. CoUninitialize();
  17. CoInitialize(NULL);
  18. }
  19.  
  20. Application::EnableVisualStyles();
  21. Application::SetCompatibleTextRenderingDefault(false);
  22.  
  23. // Create the main window and run it
  24. Application::Run(gcnew Form1());
  25. return 0;
  26. }
Add Comment
Please, Sign In to add comment