• 0

[C#] Process.Start with current path?


Question

My JavaScript sends a selected path, for example C:\files to com ActiveX, I catch it on C# like this:


[ComVisible(true)]
public string MyParam
{
get
{
return myParam;
}
set
{
myParam = value;
}
}
[/CODE]

I then launch a program like this:

[CODE]
[ComVisible(true)]
public void LaunchPlayer()
{
Process.Start("wmplayer.exe", "ANYFOLDER");
}
[/CODE]

The problem is that how do I launch the program so that it uses the current value on myparam on "anyfolder"?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

My JavaScript sends a selected path, for example C:\files to com ActiveX, I catch it on C# like this:


[ComVisible(true)]
public string MyParam
{
get
{
return myParam;
}
set
{
myParam = value;
}
}
[/CODE]

I then launch a program like this:

[CODE]
[ComVisible(true)]
public void LaunchPlayer()
{
Process.Start("wmplayer.exe", "ANYFOLDER");
}
[/CODE]

The problem is that how do I launch the program so that it uses the current value on myparam on "anyfolder"?

Wicked. Do people still use ActiveX? I have no experience in that what so ever. Have you tried Stackoverflow?

Link to comment
Share on other sites

  • 0

public void LaunchPlayer()
{
System.Diagnostics.ProcessStartInfo PSI = new System.Diagnostics.ProcessStartInfo();
PSI.FileName = "wmplayer.exe";
PSI.WorkingDirectory = "C:\\MyDirectory";
System.Diagnostics.Process.Start(PSI);
}
[/CODE]

Link to comment
Share on other sites

  • 0

Unless I understood the OP's question incorrectly, this should do the trick:

Process.Start("wmplayer.exe", myParam);[/CODE]

The second parameter specifies the arguments passed to the executable. If you want to launch the executable with a different working directory, you should follow stumper66's suggestion above and set the WorkingDirectory property accordingly.

Link to comment
Share on other sites

  • 0

Wicked. Do people still use ActiveX? I have no experience in that what so ever. Have you tried Stackoverflow?

Is there anything better that I can use? I use ActiveX so that I can send parameters from javascript to methods in .dll.

Link to comment
Share on other sites

  • 0

Is there anything better that I can use? I use ActiveX so that I can send parameters from javascript to methods in .dll.

From the way you are using it, doubt there is another way other than COM (am I wrong to assume you are actually using COM and not ActiveX which is a variant of COM/OLE and used primarily for shared UI controls?)
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.