[C#] a own Launcher in Work.
#4

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();
}



Messages In This Thread
[No subject] - by Nikolee - 04-21-2012, 10:44 PM
[No subject] - by HateMe - 04-21-2012, 11:08 PM
[No subject] - by Nikolee - 04-21-2012, 11:12 PM
[No subject] - by HateMe - 04-21-2012, 11:20 PM
[No subject] - by Nikolee - 04-21-2012, 11:41 PM
[No subject] - by someone - 04-22-2012, 08:58 AM
[No subject] - by HateMe - 04-22-2012, 12:42 PM
[No subject] - by Nikolee - 04-22-2012, 02:06 PM
[No subject] - by Nikolee - 04-22-2012, 03:25 PM
[No subject] - by someone - 04-22-2012, 03:44 PM
[No subject] - by HateMe - 04-22-2012, 04:29 PM
[No subject] - by Nikolee - 04-22-2012, 04:45 PM
[No subject] - by HateMe - 04-22-2012, 05:20 PM
[No subject] - by Nikolee - 04-22-2012, 08:28 PM
[No subject] - by someone - 04-23-2012, 12:36 PM
[No subject] - by Nikolee - 04-23-2012, 02:38 PM
[No subject] - by HateMe - 04-23-2012, 03:18 PM
[No subject] - by Nikolee - 04-23-2012, 05:02 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)