CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2012
    Posts
    2

    Question May i get some help.

    Hey, i hope you guys/girls can help me.
    Im kind of new to c++, learned a bit so far.
    Anyway, im working on a program with some functions i've added.
    But now im stuck.

    I'm trying to run a program called Tor, with the help of a button.

    But i really cant get it to work.
    Looked at CreateProcess() and ShellExecute().

    Is i said, yeah im a newbie.
    Would appreciate some help to fix it into the code, and give me an explanation how you did it and what i should remember.

    Here is the code
    Code:
    #pragma once
    
    namespace SmoothBrowser {
    
    	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
    	/// </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::WebBrowser^  web;
    	protected: 
    
    
    
    	private: System::Windows::Forms::TextBox^  tbx;
    	private: System::Windows::Forms::Button^  button1;
    	private: System::Windows::Forms::Button^  button2;
    	private: System::Windows::Forms::Button^  button3;
    	private: System::Windows::Forms::ProgressBar^  progressBar1;
    	private: System::Windows::Forms::Button^  button4;
    	private: System::Windows::Forms::WebBrowser^  webBrowser1;
    	private: System::Windows::Forms::LinkLabel^  linkLabel1;
    	private: System::Windows::Forms::Button^  button5;
    
    
    
    
    
    
    
    
    
    
    	private: System::ComponentModel::IContainer^  components;
    
    	protected: 
    
    	private:
    		/// <summary>
    		/// Required designer variable.
    		/// </summary>
    
    
    #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)
    		{
    			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
    			this->web = (gcnew System::Windows::Forms::WebBrowser());
    			this->tbx = (gcnew System::Windows::Forms::TextBox());
    			this->button1 = (gcnew System::Windows::Forms::Button());
    			this->button2 = (gcnew System::Windows::Forms::Button());
    			this->button3 = (gcnew System::Windows::Forms::Button());
    			this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
    			this->button4 = (gcnew System::Windows::Forms::Button());
    			this->webBrowser1 = (gcnew System::Windows::Forms::WebBrowser());
    			this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
    			this->button5 = (gcnew System::Windows::Forms::Button());
    			this->SuspendLayout();
    			// 
    			// web
    			// 
    			this->web->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
    				| System::Windows::Forms::AnchorStyles::Left) 
    				| System::Windows::Forms::AnchorStyles::Right));
    			this->web->Location = System::Drawing::Point(0, 65);
    			this->web->MinimumSize = System::Drawing::Size(20, 20);
    			this->web->Name = L"web";
    			this->web->Size = System::Drawing::Size(878, 490);
    			this->web->TabIndex = 0;
    			this->web->Url = (gcnew System::Uri(L"http://smooth.vattenparlor.org/browser/index.html", System::UriKind::Absolute));
    			this->web->DocumentCompleted += gcnew System::Windows::Forms::WebBrowserDocumentCompletedEventHandler(this, &Form1::web_DocumentCompleted);
    			// 
    			// tbx
    			// 
    			this->tbx->Dock = System::Windows::Forms::DockStyle::Top;
    			this->tbx->Location = System::Drawing::Point(0, 0);
    			this->tbx->Name = L"tbx";
    			this->tbx->Size = System::Drawing::Size(877, 20);
    			this->tbx->TabIndex = 3;
    			this->tbx->Text = L"http://";
    			this->tbx->TextChanged += gcnew System::EventHandler(this, &Form1::tbx_TextChanged);
    			// 
    			// button1
    			// 
    			this->button1->Location = System::Drawing::Point(65, 26);
    			this->button1->Name = L"button1";
    			this->button1->Size = System::Drawing::Size(50, 19);
    			this->button1->TabIndex = 4;
    			this->button1->Text = L"Go";
    			this->button1->UseVisualStyleBackColor = true;
    			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    			// 
    			// button2
    			// 
    			this->button2->Location = System::Drawing::Point(12, 26);
    			this->button2->Name = L"button2";
    			this->button2->Size = System::Drawing::Size(47, 19);
    			this->button2->TabIndex = 5;
    			this->button2->Text = L"<---";
    			this->button2->UseVisualStyleBackColor = true;
    			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
    			// 
    			// button3
    			// 
    			this->button3->Location = System::Drawing::Point(122, 26);
    			this->button3->Name = L"button3";
    			this->button3->Size = System::Drawing::Size(46, 19);
    			this->button3->TabIndex = 6;
    			this->button3->Text = L"--->";
    			this->button3->UseVisualStyleBackColor = true;
    			this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
    			// 
    			// progressBar1
    			// 
    			this->progressBar1->AccessibleRole = System::Windows::Forms::AccessibleRole::IpAddress;
    			this->progressBar1->Location = System::Drawing::Point(12, 51);
    			this->progressBar1->Name = L"progressBar1";
    			this->progressBar1->Size = System::Drawing::Size(156, 10);
    			this->progressBar1->TabIndex = 7;
    			this->progressBar1->Click += gcnew System::EventHandler(this, &Form1::progressBar1_Click);
    			// 
    			// button4
    			// 
    			this->button4->ForeColor = System::Drawing::SystemColors::HotTrack;
    			this->button4->Location = System::Drawing::Point(174, 26);
    			this->button4->Name = L"button4";
    			this->button4->Size = System::Drawing::Size(36, 35);
    			this->button4->TabIndex = 8;
    			this->button4->Text = L"HP";
    			this->button4->UseVisualStyleBackColor = true;
    			this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
    			// 
    			// webBrowser1
    			// 
    			this->webBrowser1->Location = System::Drawing::Point(0, 65);
    			this->webBrowser1->MinimumSize = System::Drawing::Size(20, 20);
    			this->webBrowser1->Name = L"webBrowser1";
    			this->webBrowser1->ScrollBarsEnabled = false;
    			this->webBrowser1->Size = System::Drawing::Size(115, 20);
    			this->webBrowser1->TabIndex = 9;
    			this->webBrowser1->Url = (gcnew System::Uri(L"http://smooth.vattenparlor.org/browser/ip.html", System::UriKind::Absolute));
    			// 
    			// linkLabel1
    			// 
    			this->linkLabel1->AutoSize = true;
    			this->linkLabel1->LinkColor = System::Drawing::Color::DarkGray;
    			this->linkLabel1->Location = System::Drawing::Point(310, 37);
    			this->linkLabel1->Name = L"linkLabel1";
    			this->linkLabel1->Size = System::Drawing::Size(28, 13);
    			this->linkLabel1->TabIndex = 10;
    			this->linkLabel1->TabStop = true;
    			this->linkLabel1->Text = L"Blog";
    			this->linkLabel1->VisitedLinkColor = System::Drawing::Color::DarkGray;
    			// 
    			// button5
    			// 
    			this->button5->Location = System::Drawing::Point(217, 26);
    			this->button5->Name = L"button5";
    			this->button5->Size = System::Drawing::Size(87, 33);
    			this->button5->TabIndex = 11;
    			this->button5->Text = L"Tor Proxy";
    			this->button5->UseVisualStyleBackColor = true;
    			this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click_1);
    			// 
    			// Form1
    			// 
    			this->AcceptButton = this->button1;
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->AutoValidate = System::Windows::Forms::AutoValidate::Disable;
    			this->ClientSize = System::Drawing::Size(877, 554);
    			this->Controls->Add(this->button5);
    			this->Controls->Add(this->linkLabel1);
    			this->Controls->Add(this->webBrowser1);
    			this->Controls->Add(this->button4);
    			this->Controls->Add(this->progressBar1);
    			this->Controls->Add(this->button3);
    			this->Controls->Add(this->button2);
    			this->Controls->Add(this->button1);
    			this->Controls->Add(this->tbx);
    			this->Controls->Add(this->web);
    			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
    			this->Name = L"Form1";
    			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
    			this->Text = L"$mooth Browser";
    			this->ResumeLayout(false);
    			this->PerformLayout();
    
    		}
    
    
    #pragma endregion
    	private: System::Void notifyIcon1_MouseDoubleClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
    			 }
    	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) { 
    				 web->Navigate(tbx->Text);
    
    			 }
    
    private: System::Void tbx_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    		 }
    private: System::Void pictureBox1_Click(System::Object^  sender, System::EventArgs^  e) {
    		 }
    private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
    			     web->GoBack();
    				
    		 }
    private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
    			 web->GoForward();
    		 }
    private: System::Void web_DocumentCompleted(System::Object^  sender, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^  e) {
    		 }
    private: System::Void progressBar1_Click(System::Object^  sender, System::EventArgs^  e) {
    			 		 
    				 
    		 }
    private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
    
    			 web->Url = (gcnew System::Uri(L"HIDDEN", System::UriKind::Absolute));
    
    		 }
    private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
    			
    		 }
    private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
    			 web->Url = (gcnew System::Uri(L"HIDDEN", System::UriKind::Absolute));
    		 }
    private: System::Void linkLabel2_LinkClicked(System::Object^  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^  e) {
    			 web->Url = (gcnew System::Uri(L"HIDDEN", System::UriKind::Absolute));
    		 }
    private: System::Void button5_Click_1(System::Object^  sender, System::EventArgs^  e) {
    ########ITS HERE I WANT IT TO EXECUTE THE PROGRAM TOR.EXE###########
    		 }
    };
    }
    The button is at the end of this code.

    Code:
    private: System::Void button5_Click_1(System::Object^  sender, System::EventArgs^  e) {
    ########ITS HERE I WANT IT TO EXECUTE THE PROGRAM TOR.EXE###########
    		 }
    };
    And thanks.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: May i get some help.


  3. #3
    Join Date
    Sep 2012
    Posts
    2

    Re: May i get some help.

    Nvm, i solved it

    Namespace:
    using namespace System:iagnostics;

    Button1:
    Process::Start("TheProgram.exe");

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: May i get some help.

    [ Redirected thread ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured