[req]how to open a program in C++

Posts 1–15 of 22 · Page 1 of 2
[req]how to open a program in C++
i need help im new to c++


i mean for example i press a button and firefox opens whats the command to open firefox.exe

visual basic 2008 is "process.start ("Firefox.exe")"

btw i have cpp 2008
Be more specific? Like a lot more specific. What exactly do you need help with? What kind of help are you looking for? Rather, what do you mean how to open a program in c++?
Quote Originally Posted by zeco View Post
Be more specific? Like a lot more specific. What exactly do you need help with? What kind of help are you looking for? Rather, what do you mean how to open a program in c++?
i edited to be more specific... kk now i need help
If you mean you want to see the source code of an already compiled application, that's not what C++ compilers are for.
Quote Originally Posted by Stelthkid View Post
i need help im new to c++


i mean for example i press a button and firefox opens whats the command to open firefox.exe

visual basic 2008 is "process.start ("Firefox.exe")"

btw i have cpp 2008
one possible way would be to use

system ("c:/program files/mozilla/firefox.exe");

System basically allows you to access command prompt, so with using system you are basically telling c++ to send that command to cmd.
tyvm ill try this and ill get bak to u kk
it wont work send me a pic of it



fkin oops

its not a cmd its a application with buttons if thats wot your telling me
Quote Originally Posted by Stelthkid View Post
it wont work send me a pic of it



fkin oops

its not a cmd its a application with buttons if thats wot your telling me
So like windows forms? Even then it should still work, one sec let me try something out.
Quote Originally Posted by zeco View Post
So like windows forms? Even then it should still work, one sec let me try something out.
ill attach some pics kk
and can u show me a tut

bottom left hand corner where your thing is
Code:
#pragma once


namespace firstattempt {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  button1;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(0, 0);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(409, 61);
			this->button1->TabIndex = 0;
			this->button1->Text = L"button1";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(408, 191);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {system ("c:/program files/mozilla/firefox.exe");
			 }
	};
}
thats the whole thing
Quote Originally Posted by Stelthkid View Post
ill attach some pics kk
and can u show me a tut

bottom left hand corner where your thing is
Code:
#pragma once


namespace firstattempt {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  button1;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(0, 0);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(409, 61);
			this->button1->TabIndex = 0;
			this->button1->Text = L"button1";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(408, 191);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {system ("c:/program files/mozilla/firefox.exe");
			 }
	};
}
thats the whole thing
Right, after testing it i see the problem with my first method. I'll work on looking for another way.
Quote Originally Posted by zeco View Post
Right, after testing it i see the problem with my first method. I'll work on looking for another way.
tyvm im just starting to learn cpp its so hard
Quote Originally Posted by Stelthkid View Post
tyvm im just starting to learn cpp its so hard
It's not so much c++ that's hard. it's the windows API. C++ itself really isnt that difficult
well its different for me but do u know yet
Quote Originally Posted by Stelthkid View Post
well its different for me but do u know yet
Yay!

[php]
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
WinExec("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", SW_SHOW);
}
};
}


[/php]

took me forever to get it to work, then i realised you need double backslash because of the \n e*** type things, and for one backslash you need \\

ty ill try now ohk


grr it has build errors ... whats the x86 thing
Posts 1–15 of 22 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?