代码如下:
privatevoidbtnCreate_Click(objectsender,EventArgse)
…{
inthWnd=FindWindow(null,”test”);//窗體的名稱
//checkifPowerReuseislaunchedornot
//ifyes,passpathofprojecttoPowerReuse
//or,launchPowerReusewithspecifiedparameter
if(hWnd>0)
…{
MessageBox.Show(“powerReusehasbeenlaunchedalready.”+””+hWnd.ToString());
//SendMessagetoPowerReuse
return;
}
try
…{
ProcessMain_P=newProcess();
//thispathshouldberetrievedfromWindowsRegistry,
//theloactioniswrittenbyInstallterduringprocessofinstallation.
Main_P.StartInfo.FileName=@”C:est.exe”;//運行的exe路徑
//ThisURLispassedtoPowerReusetoopen
Main_P.StartInfo.Arguments=@”C:Tempabc.prj”;//運行時的參數
Main_P.StartInfo.UseShellExecute=true;
Main_P.Start();
//
//wehavetowaitforawhileuntilUIhasbeeninitialized
//
Main_P.WaitForInputIdle(10000);
//althoughUIhasbeeninitialzied,
//itdoesnotmeanmainformofapplicationhasbeencompleted.
//wemaywaitforanother10seconds
for(inti=0;i<100;i++)
…{
hWnd=FindWindow(null,”PowerReuse(Beta)”);
//hWnd=Main_P.MainWindowHandle.ToInt32();
if(hWnd>0)break;
Thread.Sleep(100);
}
//Here,wecheckifPowerReuseisfullylaunched
if(hWnd==0)
…{
//Handleexception
MessageBox.Show(“WecannotfindwindowhandleofPowerReuse”);
}
else
…{
//otherhandling
//
MessageBox.Show(hWnd.ToString()+””+Main_P.MainWindowHandle.ToString()+””+Main_P.MainWindowTitle);
}
}
catch(Exceptionex)
…{
MessageBox.Show(ex.Message);
}
}
Cocos2d-x 3.x入门教程(二):Node节点类
Cocos2d-x 3.x入门教程(一):基础概念
上述就是C#学习教程:用C#实现启动另一程序的方法实例分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/904890.html