[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

parsing parameter from a .net WIN-GUI application to a win32 console app.

Posted on 2005-04-23
11
Medium Priority
?
231 Views
Last Modified: 2010-04-16
the application uses 2 parameters like: myConsole <input-file> <output-file>, and is well tested and functional from the command-prompt!
When using the .net windows-application, a process is created by the usage of Process.StartInfo properties, like FileName and StartInfo.Arguments... but the application does not respond... what am I doing wrong?
0
Comment
Question by:faroeseTelecom
  • 5
  • 5
11 Comments
 
LVL 14

Expert Comment

by:existenz2
ID: 13849210
Can you post the code you are using for it? We can help you better that way.
0
 

Author Comment

by:faroeseTelecom
ID: 13849270
Process myProcess = new Process();    //create a process - from System.Diagnostics.Process
myProcess.StartInfo.FileName = this.exeRef;     //reference to the executeble
myProcess.StartInfo.CreateNoWindow = false;  // hide the command window
myProcess.StartInfo.Arguments = this.sourceFileRef + " " + this.destFileRef;  //params: <input file> <output file>
myProcess.Start();   // starting process with exec. and params.
0
 
LVL 8

Expert Comment

by:vinhnl
ID: 13849288
You can modify method Main():

            [STAThread]
            static void Main(string[] args)
            {
                  if( args.Length >1)
                        MessageBox.Show(args[0] + " " + args[1]);
                  Application.Run(new Form1());
            }
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:vinhnl
ID: 13849304
Hi faroeseTelecom,

I tested your code. It is OK!
0
 

Author Comment

by:faroeseTelecom
ID: 13849311
the main method is not accessible - a  standard win32 (with MFC and not .net) console main method
int main(int argc, char* argv[]), that should result i a streight forward process call...

I have now tried by the process static method call:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = programReference.Text;
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = sourceFileRef + " " + destFileRef;
System.Diagnostics.Process.Start(startInfo);

...but the result is the same...
0
 

Author Comment

by:faroeseTelecom
ID: 13849322
can it be that the file references must have double-backslashes for file references on win32? ....worth the try...
0
 
LVL 8

Expert Comment

by:vinhnl
ID: 13849327
Is programReference.Text a full path? ("C:\\MyConsol.exe")
0
 

Author Comment

by:faroeseTelecom
ID: 13849346
yes all references are absolute.
0
 

Author Comment

by:faroeseTelecom
ID: 13849428
found the error - the path contains spaces to the source- and dest file, therefore was badly interpred by the executable.
0
 
LVL 8

Expert Comment

by:vinhnl
ID: 13849439
Yes, I think  sourceFileRef or destFileRef has  space char
0
 
LVL 8

Accepted Solution

by:
vinhnl earned 2000 total points
ID: 13849473
You can add char \" into sourceFileRef, destFileRef  :

sourceFileRef  = "\"" + sourceFileRef + "\"";
destFileRef = "\"" + destFileRef + "\"";

Good luck
VINHNL
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question