Code Snippets

  

C++ Source Code


Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,221 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,171 people online right now. Registration is fast and FREE... Join Now!





WxWidgets: Get the OS Start Command

Since wxWidgets is cross platform, it might be handy to be able to get the current operating system's start command, to use system() ~ that's exactly what this function does: it checks the default operating system, and returns a string of the operating system's command to start a process.

Submitted By: gabehabe
Actions:
Rating:
Views: 224

Language: C++

Last Modified: October 13, 2008

Snippet


  1. /*
  2. * A method to get the "start" command of the current operating system
  3. * Author: Danny Battison
  4. * Contact: gabehabe@googlemail.com
  5. */
  6.  
  7. #include <string>
  8.  
  9. std::string GetStartCommand() {
  10.     #if defined(__WXMSW__)
  11.         return "start";
  12.     #elif defined(__WXMAC__)
  13.         return "open";
  14.     #elif defined(__UNIX__)
  15.         return "xdg-open";
  16.     #endif
  17. }
  18.  
  19. /** EXAMPLE USAGE **/
  20. #include <wx/wx.h>
  21. class MainApp : public wxApp {
  22.     public:
  23.         bool OnInit();
  24. };
  25.  
  26. bool MainApp::OnInit() {
  27.     std::string ContactAuthor = GetStartCommand() + " mailto:gabehabe@googlemail.com";
  28.     system(ContactAuthor.c_str());
  29.  
  30.     return true;
  31. }
  32.  
  33. IMPLEMENT_APP(MainApp)
  34.  

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month