本文整理汇总了C#中System.Diagnostics.Process.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.Refresh方法的具体用法?C# System.Diagnostics.Process.Refresh怎么用?C# System.Diagnostics.Process.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了System.Diagnostics.Process.Refresh方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runNotePad
public static void runNotePad(String message)
{
#region [ 启动记事本 ]
System.Diagnostics.Process Proc;
try
{
// 启动记事本
Proc = new System.Diagnostics.Process();
Proc.StartInfo.FileName = "notepad.exe";
Proc.StartInfo.UseShellExecute = false;
Proc.StartInfo.RedirectStandardInput = true;
Proc.StartInfo.RedirectStandardOutput = true;
Proc.Start();
}
catch
{
Proc = null;
}
#endregion
#region [ 传递数据给记事本 ]
if (Proc != null)
{
// 调用 API, 传递数据
while (Proc.MainWindowHandle == IntPtr.Zero)
{
Proc.Refresh();
}
IntPtr vHandle = FindWindowEx(Proc.MainWindowHandle, IntPtr.Zero, "Edit", null);
// 传递数据给记事本
SendMessage(vHandle, WM_SETTEXT, 0, message);
}
#endregion
}
示例2: fixWorkingDirectory
public static void fixWorkingDirectory()
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
string path = Application.ExecutablePath;
int i = path.LastIndexOf('\\');
proc.StartInfo.FileName = path.Substring(i + 1);
proc.StartInfo.WorkingDirectory = path.Substring(0, i);
proc.StartInfo.Arguments = "wdfix";
proc.Start();
while (true)
{
try
{
proc.Refresh();
if (proc.Modules.Count > 1) break;
System.Threading.Thread.Sleep(10);
}
catch { }
}
Application.DoEvents();
System.Threading.Thread.Sleep(1000);
kill();
}
示例3: gMake32_Click
private void gMake32_Click(object sender, EventArgs e)
{
string fo = Application.ExecutablePath;
using (System.IO.FileStream i = new System.IO.FileStream(fo, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
fo = fo.Substring(0, fo.LastIndexOf('.')) + "32.exe";
using (System.IO.FileStream o = new System.IO.FileStream(fo, System.IO.FileMode.Create))
{
bool first = true;
byte[] buf = new byte[8192];
while (true)
{
int n = i.Read(buf, 0, buf.Length);
if (first)
{
first = false;
buf[0x218] = 3; //1=any
}
if (n <= 0) break;
o.Write(buf, 0, n);
}
}
}
System.Diagnostics.Process rs = new System.Diagnostics.Process();
rs.StartInfo.FileName = "Loopstream32.exe";
rs.StartInfo.Arguments = "sign";
rs.Start();
Application.DoEvents();
rs.Refresh();
while (!rs.HasExited)
{
Application.DoEvents();
System.Threading.Thread.Sleep(10);
}
for (int a = 0; a < 10; a++)
{
try
{
System.IO.File.Delete("Loopstream32.exe");
System.IO.File.Move("Loopstream32.exe.exe", "Loopstream32.exe");
break;
}
catch { }
System.Threading.Thread.Sleep(100);
}
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "Loopstream32.exe";
proc.Start();
proc.Refresh();
Program.kill();
}
示例4: DeployProject
//.........这里部分代码省略.........
string sAccumulatingDir = "";
try
{
foreach (string dir in sDestFolder.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries))
{
if (!(string.IsNullOrEmpty(sAccumulatingDir) && sDestType == "DTS"))
{
process.StartInfo.Arguments = string.Format("/FCreate {0};{1};\"{2}\" /SourceServer {3} ", sDestType, (sAccumulatingDir == "" ? "\\" : "\"" + sAccumulatingDir + "\""), dir, newOptions.DestinationServer);
sBatFileContents.Append("\"").Append(process.StartInfo.FileName).Append("\" ").AppendLine(process.StartInfo.Arguments);
process.Start();
process.WaitForExit();
}
if (!string.IsNullOrEmpty(sAccumulatingDir))
sAccumulatingDir += "\\";
sAccumulatingDir += dir;
}
}
catch { }
}
//loop through each package to deploy
foreach (object selected in selectedItems)
{
ProjectItem pi;
string sFileName;
string sFilePath;
if (selected is ProjectItem)
{
pi = (ProjectItem)selected;
}
else if (selected is UIHierarchyItem && ((UIHierarchyItem)selected).Object is ProjectItem)
{
pi = ((ProjectItem)((UIHierarchyItem)selected).Object);
}
else
{
continue;
}
sFileName = pi.Name;
sFilePath = pi.get_FileNames(0);
if (!sFileName.ToLower().EndsWith(".dtsx")) continue;
if (pi.Document != null && !pi.Document.Saved)
{
pi.Save("");
}
if (newOptions.DeploymentType == DtsProjectExtendedConfigurationOptions.DeploymentTypes.FilePathDestination)
{
string sDestinationPath = sDestFolder + sFileName;
if (System.IO.File.Exists(sDestinationPath))
{
System.IO.File.SetAttributes(sDestinationPath, System.IO.FileAttributes.Normal);
}
sBatFileContents.Append("xcopy \"").Append(sFilePath).Append("\" \"").Append(sDestFolder).AppendLine("\" /Y /R");
System.IO.File.Copy(sFilePath, sDestinationPath, true);
outputWindow.ReportStatusMessage("Deployed " + sFileName);
}
else
{
process.Refresh();
process.StartInfo.Arguments = string.Format("/FILE \"{0}\" /DestServer {1} /COPY {2};\"{3}\" /Q", sFilePath, newOptions.DestinationServer, sDestType, sDestFolder + sFileName.Substring(0, sFileName.Length - ".dtsx".Length));
sBatFileContents.Append("\"").Append(process.StartInfo.FileName).Append("\" ").AppendLine(process.StartInfo.Arguments);
process.Start();
string sError = process.StandardError.ReadToEnd();
string sStandardOutput = process.StandardOutput.ReadToEnd();
process.WaitForExit();
if (process.ExitCode > 0)
{
outputWindow.ReportStatusError(OutputWindowErrorSeverity.Error, "BIDS Helper encountered an error when deploying package " + sFileName + "!\r\n\"" + process.StartInfo.FileName + "\" " + process.StartInfo.Arguments + "\r\nexit code = " + process.ExitCode + "\r\n" + sStandardOutput);
this.ApplicationObject.ToolWindows.OutputWindow.Parent.AutoHides = false; //pin the window open so you can see the problem
return;
}
outputWindow.ReportStatusMessage("Deployed " + sFileName);
System.Windows.Forms.Application.DoEvents();
}
}
outputWindow.ReportStatusMessage("BIDS Helper completed deploying packages successfully.");
if (bCreateBat)
{
string sBatFilename = System.IO.Path.GetDirectoryName(((Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)proj).FullName);
sBatFilename += "\\" + newOptions.OutputPath;
if (!System.IO.Directory.Exists(sBatFilename))
System.IO.Directory.CreateDirectory(sBatFilename);
sBatFilename += "\\bidsHelperDeployPackages.bat";
if (System.IO.File.Exists(sBatFilename))
{
System.IO.File.SetAttributes(sBatFilename, System.IO.FileAttributes.Normal);
}
System.IO.File.WriteAllText(sBatFilename, sBatFileContents.ToString());
outputWindow.ReportStatusMessage("Deployment commands saved to: " + sBatFilename + "\r\n\r\n");
}
}
catch (Exception ex)
{
outputWindow.ReportStatusError(OutputWindowErrorSeverity.Error, "BIDS Helper encountered an error when deploying packages:\r\n" + ex.Message + "\r\n" + ex.StackTrace);
this.ApplicationObject.ToolWindows.OutputWindow.Parent.AutoHides = false; //pin the window open so you can see the problem
}
}
示例5: MenuSyncFunction
//.........这里部分代码省略.........
}
}
}
else
{
// 如果记事本启动成功,则将数据面板中的数据提交给记事本,否则发送到内存中。
for (int i = 0; i < StartPort.s_serialPort.Length; i++)
{
if (StartPort.s_serialPort[i].RTxtMsg != null)
{
if (StartPort.s_serialPort[i].RTxtMsg.Focused)
{
if (blnNotepad)
{
strTran = StartPort.s_serialPort[i].RTxtMsg.Text.Replace("\n", "\r\n");
}
else
{
StartPort.s_serialPort[i].RTxtMsg.SelectAll();
StartPort.s_serialPort[i].RTxtMsg.Copy();
}
break;
}
}
if (StartPort.s_serialPort[i].RTxtMsgc != null)
{
if (StartPort.s_serialPort[i].RTxtMsgc.Focused)
{
if (blnNotepad)
{
strTran = StartPort.s_serialPort[i].RTxtMsgc.Text.Replace("\n", "\r\n");
}
else
{
StartPort.s_serialPort[i].RTxtMsgc.SelectAll();
StartPort.s_serialPort[i].RTxtMsgc.Copy();
}
break;
}
}
if (StartPort.s_serialPort[i].RTxtMsge != null)
{
if (StartPort.s_serialPort[i].RTxtMsge.Focused)
{
if (blnNotepad)
{
strTran = StartPort.s_serialPort[i].RTxtMsge.Text.Replace("\n", "\r\n");
}
else
{
StartPort.s_serialPort[i].RTxtMsge.SelectAll();
StartPort.s_serialPort[i].RTxtMsge.Copy();
}
break;
}
}
if (StartPort.s_serialPort[i].RTxtMsgo != null)
{
if (StartPort.s_serialPort[i].RTxtMsgo.Focused)
{
if (blnNotepad)
{
strTran = StartPort.s_serialPort[i].RTxtMsgo.Text.Replace("\n", "\r\n");
}
else
{
StartPort.s_serialPort[i].RTxtMsgo.SelectAll();
StartPort.s_serialPort[i].RTxtMsgo.Copy();
}
break;
}
}
}
}
#endregion
#region [ 传递数据给记事本 ]
if (blnNotepad && Proc != null)
{
// 调用 API, 传递数据
while (Proc.MainWindowHandle == IntPtr.Zero)
{
Proc.Refresh();
}
IntPtr vHandle = FindWindowEx(Proc.MainWindowHandle, IntPtr.Zero, "Edit", null);
// 传递数据给记事本
SendMessage(vHandle, WM_SETTEXT, 0, strTran);
}
#endregion
};
}