Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 18th, 2005, 3:08 PM   #1
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
C++ to C# vice versa

I don't know if this is supposed to be in the C# forum or C++ because its a question for both, but C++ seems to get more attention so i'll post here.

Lets say i have a program coded in C#. The program consists of a gui, with a single button with the name hello.

Now over here, i have a C++ program, it is written as a console app though, with a command that displays the word "hello" on your desktop, in a window.

What i want to do is "combine" the C# gui program's button with the C++ console app's hello command so that when you click on the "hello" button in the C# program, the C++ program will run, and execute the hello command, If the C++ program is already running though, i don't want it to run another instance, just execute the command on the C++ app thats already running. Thanks.

p.s might as well include in here, if anyone knows where a good tutorial for running console programs in the backround or maybe if theres just a simple code needed, that would be appreciated.. i will look around though.
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!
jayme is offline   Reply With Quote
Old Nov 18th, 2005, 3:16 PM   #2
ChiHappens
Programmer
 
ChiHappens's Avatar
 
Join Date: Sep 2005
Location: Brevard, NC
Posts: 35
Rep Power: 0 ChiHappens is an unknown quantity at this point
Send a message via MSN to ChiHappens
In C#, use the Process to launch that app.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Diagnostics.Process HelloProc = new System.Diagnostics.Process();
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

HelloProc.StartInfo.FileName = "hello.exe";
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#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>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(192, 104);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
bool RunIt = true;
try
{
RunIt = HelloProc.HasExited;
}
catch{}
if(RunIt)
{
try
{
HelloProc.Start();
}
catch{}
}
}
}
}

Chi
__________________
http://www.starshipcombatsimulator.com
They mostly come at night...mostly.
ChiHappens is offline   Reply With Quote
Old Nov 18th, 2005, 3:27 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Please see the forum rules regarding the use of code tags.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 18th, 2005, 3:58 PM   #4
ChiHappens
Programmer
 
ChiHappens's Avatar
 
Join Date: Sep 2005
Location: Brevard, NC
Posts: 35
Rep Power: 0 ChiHappens is an unknown quantity at this point
Send a message via MSN to ChiHappens
Please could you post a link to them (forum rules...I don't see a link on the home page for them)? I didn't realize I had to do something special in order to post here. Also...why can't I edit that post?


Found em:http://www.programmingforums.org/for...#faq_faq_rules

These should really be accessible from the homepage....
__________________
http://www.starshipcombatsimulator.com
They mostly come at night...mostly.
ChiHappens is offline   Reply With Quote
Old Nov 18th, 2005, 4:24 PM   #5
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
There is also a sticky post "How to post a question" at the top of the C++ forum, which discusses how to ask a question to increase your chances of getting a useful answer. Th fact you didn't use code tags suggests you didn't bother to read that either.

In any event, the question (and answer given) are really C# specific. The mechanisms by which a C# program will execute another program are C# specific.
grumpy is offline   Reply With Quote
Old Nov 19th, 2005, 2:20 AM   #6
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
as to editing, you only have a certain amount of time after you've posted to edit. this is for correcting minor errors or adding a stement or so. it prevents totally recanting and/or invalidating all subsequent posts.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Nov 19th, 2005, 3:25 AM   #7
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Quote:
Originally Posted by bl00dninja
as to editing, you only have a certain amount of time after you've posted to edit. this is for correcting minor errors or adding a stement or so. it prevents totally recanting and/or invalidating all subsequent posts.
Hmmmm..... I sometimes wonder about the value of that.

Occasionally, after looking through a thread, I pick up minor errors in my past posts (eg in a code example, setting a flag to true when it should be set to false) that have not been picked up and discussed to death in subsequent posts by others. It would be nice to be able to fix those even if I pick them up a month after the original post.

Tough balance, I know. Distinguishing between minor corrections and complete recanting of previous information, a month after the fact, would be difficult for even a human moderator to pick up.
grumpy is offline   Reply With Quote
Old Nov 19th, 2005, 8:36 AM   #8
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by grumpy
Hmmmm..... I sometimes wonder about the value of that.

Occasionally, after looking through a thread, I pick up minor errors in my past posts (eg in a code example, setting a flag to true when it should be set to false) that have not been picked up and discussed to death in subsequent posts by others. It would be nice to be able to fix those even if I pick them up a month after the original post.

Tough balance, I know. Distinguishing between minor corrections and complete recanting of previous information, a month after the fact, would be difficult for even a human moderator to pick up.
I agree, maybe we should have some kind of threshold for changing a percentage of your posts. I have seen it somewhere before, you can edit like 5% of your post, or in any case, just a bit of it. In the beginning one should be able to completely change a post, after some time, the threshold will stop one from completely changing a post. What do you think of the idea? (Big_K could something like this be implemented?)
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:24 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC