![]() |
|
[C#] a own Launcher in Work. - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196) +---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192) +---- Thread: [C#] a own Launcher in Work. (/showthread.php?tid=770) Pages:
1
2
|
- Nikolee - 04-21-2012 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?^^ - HateMe - 04-21-2012 thats simpel ![]() //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(); } EP2 is "Nksp.StartInfo.Arguments = "4022";" EP1 is "Nksp.StartInfo.Arguments = "6574";" - Nikolee - 04-21-2012 Which kontext i need to use? German : öhm muss ich da noch was ergänzen mit using? - HateMe - 04-21-2012 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(); } - Nikolee - 04-21-2012 2 That error shows with youre code . And my look so atm : 2 and works^^ - someone - 04-22-2012 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(). - HateMe - 04-22-2012 2 That error shows with youre code . And my look so atm : 2 and works^^ thats right like someone say alredy u need add using System.IO; to. and take out the start.Enabled = false; its bc i did name the button "start" and yes i believe that there are bether ways to start an exe over c++ ![]() - Nikolee - 04-22-2012 im almost done , look ![]() :http://s7.directupload.net/file/d/2868/d94jaasv_png.htm Now i try to implent the Updating^^ only for learn a bit c#^^ - Nikolee - 04-22-2012 Help me a bit, i wanna make an Progressbar which shows then an Update is done, buzt the probleme is the pbar only load then i klick on it.. And how i can set that it dont update everytime then i start the launcher?^^ 2 - someone - 04-22-2012 I think the info on the prograssBar1_click should be in the updateButton_click, you can modify the progress bar by accessing the variable attached to your progress bar(in your case prograssBar1). Dont forget to set your progress bar maximun and minimun(min = 0, and max = 100). in your updateButton_click, will be: Download patch: set progress bar at 50%(progressBar1.increment(50) ![]() Apply patch setprogress bar at 100%(progressBar1.increment(50) ![]() To check if you got 100% you could just use: if(progressBar1.value >= progressBar1.Maximum){ //progress bar is full } |