能否用c#命令window開程式?
能否用c#命令window開程式?如exe檔我想用上次"報上名來器"的button黎將我windows的程式檔直接開啟..
大家都知啦,一入window,就想立即開日常用的功能 如msn,web,game等..唔洗開咁多"捷徑"放係桌面又晒位又唔靚....
如button1是開msn,button2是開game,,,
高人指點一下^_^:onion112
[[i] 本帖最後由 tom1991 於 2008-9-22 23:54 編輯 [/i]] Sure
in this case you need to use
using System.Diagnostics; //at the top
//somewhere in the program
Process myProcess = new Process(); // create a process
string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); //find the path of the folder, in this case, i assume they are in the same folder
myProcess.StartInfo.FileName = myDocumentsPath + "\\file.exe"; //add the filename at the end
myProcess.Start(); // trigger the process to start [quote]
System.Diagnostics.Process.Start("firefox.exe")
[/quote]
:onion126 [quote]原帖由 [i]ivanyung[/i] 於 2008-9-23 09:21 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=573951&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
:onion126 [/quote]試緊~~:onion138 firefox同excel我都冇-_- [quote]原帖由 [i]tom1991[/i] 於 2008-9-23 16:26 發表 [url=http://www.cnet.hk/bbs/redirect.php?goto=findpost&pid=574976&ptid=62032][img]http://www.cnet.hk/bbs/images/common/back.gif[/img][/url]
firefox同excel我都冇-_- [/quote]
:onion126我無 msn ... 快快做了個自訂 launch program ...
將 process.txt 內容改為你雖要啟動的程式即可 ... :onion156
其中 bname1 為 button 名稱
而 bexe1 為要啟動之程式的 full path ...
[attach]12429[/attach] </bexe2>係咩文字黎/__\
噢.問問....只要寫呢幾句就可以?
程式開頭如using system果d呢
[[i] 本帖最後由 tom1991 於 2008-9-23 21:23 編輯 [/i]] [quote]原帖由 [i]tom1991[/i] 於 2008-9-23 21:20 發表 [url=http://sumcc.net/bbs/redirect.php?goto=findpost&pid=575562&ptid=62032][img]http://sumcc.net/bbs/images/common/back.gif[/img][/url]
係咩文字黎/__\
噢.問問....只要寫呢幾句就可以?
程式開頭如using system果d呢 [/quote]
:onion036我諗依D題目的program...............網上大把~
搞唔好用google,或直接查c#教學文件都會有?:onion080 [quote]原帖由 [i]cliff[/i] 於 2008-9-23 07:51 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=573858&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
Sure
in this case you need to use
using System.Diagnostics; //at the top
//somewhere in the program
Process myProcess = new Process(); // create a process
string myDocumentsPath = Environme ... [/quote]
佢沒error,但...
[[i] 本帖最後由 tom1991 於 2008-9-23 22:50 編輯 [/i]] 最新情況..已經開到第一個程式..
但myProcess.StartInfo.FileName = MyDocumentsPath +[color=red] [/color][color=red]\[/color][color=red]\[/color]
[color=red]MPoint.exe[/color][color=red];[/color]
這個\\ 是什麼意思?
此外...紅,藍圈又是代表咩野?
[[i] 本帖最後由 tom1991 於 2008-9-23 22:20 編輯 [/i]] [quote]原帖由 [i]tom1991[/i] 於 2008-9-23 21:20 發表 [url=http://www.cnet.hk/bbs/redirect.php?goto=findpost&pid=575562&ptid=62032][img]http://www.cnet.hk/bbs/images/common/back.gif[/img][/url]
係咩文字黎/__\
噢.問問....只要寫呢幾句就可以?
程式開頭如using system果d呢 [/quote]
不是呀,果個文字檔是用來記錄要啟動的程式的路徑 ...
bexe1 只是自訂的文字, 代表 button 1
bexe2 就是 button 2
bname1 是 button1 上顯示的文字, 而 bname2 就是 button2 ...
只要將想啟動的 program 的 fullpath 加入到 <bexe1> 和 </bexe1> 即可
<bexe2> 是指第 2 個 button [quote]原帖由 [i]tom1991[/i] 於 2008-9-23 21:34 發表 [url=http://www.cnet.hk/bbs/redirect.php?goto=findpost&pid=575594&ptid=62032][img]http://www.cnet.hk/bbs/images/common/back.gif[/img][/url]
佢沒error,但... [/quote]
:onion126我估 Cliff 所只的 mpoint.exe 是一個例子,tom 要將想啟動的 program 名換到這裡 ... :onion149
see you ... [quote]原帖由 [i]ivanyung[/i] 於 2008-9-23 22:10 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=575767&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
不是呀,果個文字檔是用來記錄要啟動的程式的路徑 ...
bexe1 只是自訂的文字, 代表 button 1
bexe2 就是 button 2
bname1 是 button1 上顯示的文字, 而 bname2 就是 button2 ...
只要將想啟動的 program 的 fu ... [/quote]係唔係c#語言黎嫁-_-我怕用唔到.... <tom> ... </tom> is XML language ... :onion160
我唔識 C#, tom 有時間教吓我 C# ... :onion022 [quote]原帖由 [i]ivanyung[/i] 於 2008-9-24 09:15 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=576408&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
... is XML language ... :onion160
我唔識 C#, tom 有時間教吓我 C# ... :onion022 [/quote]咁我c#咪用唔到囉-.-:onion112 己經幫您寫左兩個 button ... 你將 process.txt 內的 c:\HERE.EXE 改成你自己喜歡的程式,接著運行 processstart.exe 即可 ...
<bexe1>c:\HERE.EXE</bexe1>
C# 絶對可以用 XML ... 不過我唔識 ... :onion165
開工啦 ... :onion022 [quote]原帖由 [i]tom1991[/i] 於 2008-9-23 21:40 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=575626&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
最新情況..已經開到第一個程式..
但myProcess.StartInfo.FileName = MyDocumentsPath + \\
MPoint.exe;
這個\\ 是什麼意思?
此外...紅,藍圈又是代表咩野? [/quote]
because '\' can be used in things like \n, \r, \t, \b.....
so in order to display the correct char '\', use double \\
Environment.GetFolderPath() is a static method to get the path of the folder that you specify.
Static method means you can use the method without create an instance of the object.
may be I didn't explain clearly enough, for simplicity, use the following:
using System.Diagnostics; //at the top
//somewhere in the program
Process myProcess = new Process(); // create a process
myProcess.StartInfo.FileName = "C:\\file.exe"; //add the file path
myProcess.Start(); // trigger the process to start
===========
remember to change "C:\\file.exe" to the actual path of the file. [quote]原帖由 [i]ivanyung[/i] 於 2008-9-24 09:29 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=576459&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
己經幫您寫左兩個 button ... 你將 process.txt 內的 c:\HERE.EXE 改成你自己喜歡的程式,接著運行 processstart.exe 即可 ...
c:\HERE.EXE
C# 絶對可以用 XML ... 不過我唔識 ... :onion165
開工啦 ... [/quote]
C# manipluates XML is very simple.
Just use the example in MSDN:
http://support.microsoft.com/kb/307548/zh-tw
another one from a Chinese site:
http://developer.51cto.com/art/200610/32906.htm [quote]原帖由 [i]tom1991[/i] 於 2008-9-23 21:34 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=575594&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
佢沒error,但... [/quote]
Are you sure the path is correct? [quote]原帖由 [i]cliff[/i] 於 2008-9-24 13:55 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=577033&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
Are you sure the path is correct? [/quote]噢,果個搞店左,宜家睇緊其他 [quote]原帖由 [i]cliff[/i] 於 2008-9-24 13:53 發表 [url=http://cnet.hk/bbs/redirect.php?goto=findpost&pid=577019&ptid=62032][img]http://cnet.hk/bbs/images/common/back.gif[/img][/url]
because '\' can be used in things like \n, \r, \t, \b.....
so in order to display the correct char '\', use double \\
Environment.GetFolderPath() is a static method to get the path of the folder ... [/quote]用到了,多謝晒>_<":onion004 遲下我多學下 C# 先 ...
頁:
[1]
2