Posts: 528
Threads: 50
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: Oct 2011
Reputation:
0
Since i started to Learn C# i got some problems to create a Launcher.
The Problem is:
I Can run the "nksp" on my Computer with "C:\...."
but how i can run it on other Computers?
Thats at the moment the only problem, hope you can help me ^^
string currentDir = Environment.CurrentDirectory;
Process.Start(currentDir@"\bin\nksp.exe");
System.Media.SoundPlayer sp = new System.Media.SoundPlayer(@"C:\Users\BOSS\Music\LC Musik\test.wav");
Look the Process.Start line, what i must edit there?^^
Posts: 528
Threads: 50
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: Oct 2011
Reputation:
0
Which kontext i need to use?
German : öhm muss ich da noch was ergänzen mit using?
Posts: 335
Threads: 22
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: Aug 2011
Reputation:
0
put the code for example in a button
on
C#
add first
using System.Diagnostics;
....
// Starting the programm
private void start_Click(object sender, EventArgs e)
{
//Starting the exe
if (File.Exists("Bin\\Nksp.exe"))
{
Process Nksp = new Process();
Nksp.StartInfo.FileName = "Bin\\Nksp.exe";
Nksp.StartInfo.Arguments = "4022";
Nksp.Start();
this.close();
}
}
C++
void RunApplication(LPCTSTR FileName, LPCTSTR FileParam)
{
int ret = (int) ShellExecute(NULL, "open", FileName, FileParam, NULL, SW_SHOWNORMAL);
if (ret <= 32)
{
AnsiString msg;
switch(ret)
{
case ERROR_FILE_NOT_FOUND, SE_ERR_FNF :
msg = "File " + AnsiString(FileName) + " not found!";
break;
case ERROR_PATH_NOT_FOUND, SE_ERR_PNF :
msg = "Directory " + AnsiString(FileName) + " not found!";
break;
case ERROR_BAD_FORMAT :
msg = "The application is broken or cant run!";
break;
case SE_ERR_ACCESSDENIED, SE_ERR_SHARE :
msg = "Der Zugriff auf die Datei " + AnsiString(FileName) + " wurde vom Betriebssystem verweigert!";
break;
case SE_ERR_ASSOCINCOMPLETE, SE_ERR_NOASSOC :
msg = "Der angegebene Dateityp ist auf Ihrem Computer keiner Anwendung zugeordnet!";
break;
case 0, SE_ERR_OOM :
msg = "To run this Application u have not enough memory space!";
break;
default : msg = "Data " + AnsiString(FileName) + " could not opened!";
}
Application->MessageBox(msg.c_str(), "ERROR", MB_OK + MB_ICONERROR);
}
}
// Here is the button
void __fastcall TForm1::Button_StartClick(TObject *Sender)
{
AnsiString FileName = "Bin\\Nksp.exe";
AnsiString Parameter = "4022";
RunApplication(FileName.c_str(), Parameter.c_str());
// Close the Application
this->Close();
}
Posts: 313
Threads: 20
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: Jul 2011
Reputation:
0
Add this:
using System.IO;
I dont know what start is supposed to mean.
@HateMe there are other things that make the code simpler in C++.
Try to use FormatMessage to get a string for the error message, instead of writing manually write your error. Or the alternative _com_error::ErrorMessage().