我很好奇,int main函数在Cocoa程序中扮演什么角色?实际上,我一直在查看的所有示例代码在main.m中只有以下代码:
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}
Run Code Online (Sandbox Code Playgroud)
这究竟是做什么的,程序实际上从哪里开始逐步执行命令?看来我的观念需要重新调整.
我正在使用Netbeans 6.5.1(包括tomcat 6.0.18)
我在netbeans上开发了很多webapp项目.我为每个webapp创建了一个contextlistener,它在contextInitialized方法中打印出"Hello World!this is <>".
每当我单击"运行主项目"按钮(或在项目上单击鼠标右键并选择"运行")时,我可以在tomcat的输出窗口中看到所有其他项目也在运行.
我的意思是,当我运行一个项目(任何项目)时,我可以看到我的所有webapps都调用它们各自的上下文监听器!最糟糕的情况是webapp使用hibernate时:每个webapp都执行所有相关的hibernate初始化工作.
有没有办法只运行我想要的项目?
我已经尝试关闭其他项目,但这不起作用.
问题:您在ubuntu上的"运行应用程序"框中输入什么命令来打开终端?
信息:我在上网本上遇到了可怕的驱动程序问题.我可能能够解决其中的一些问题,如果我可以到达终端,但我只有我的键盘,没有鼠标,所以我需要知道输入应用程序的输入命令(我可以使用alt -f2)打开终端.
是否可以运行任何基于命令行的程序或批处理文件和捕获器(重定向)输出到文本框LIVE
CL需要时间并产生文本!
类似于tracert.exe(需要时间并产生大量文本).
实际上我将使用tracert.exe,我喜欢实时捕获输出并在运行时在文本框中显示它
编辑:我的问题是让它生活我的意思是控制台产生的任何新行或字符将被发送/拉到/由textBox,直到程序完成!
我想构建的就像这个http://www.codeproject.com/KB/threads/redir.aspx (查看演示),但在C#中
这是我的代码:
private void button1_Click(object sender, EventArgs e)
{
Process pc = new Process();
pc.StartInfo.FileName = "tracert.exe";
pc.StartInfo.Arguments = "google.com";
pc.StartInfo.UseShellExecute = false;
pc.StartInfo.RedirectStandardOutput = true;
pc.StartInfo.CreateNoWindow = true;
pc.Start();
richTextBox1.Text = pc.StandardOutput.ReadToEnd();
pc.WaitForExit();
}
Run Code Online (Sandbox Code Playgroud)
编辑
在你的帮助下(非常感谢)和这个链接:http: //msdn.microsoft.com/query/dev10.query?appId = Dev10IDEF1&l = EN-US&k = k%28EHINVALIDOPERATION.WINFORMS.ILLEGALCROSSTHREADCALL%29; k% 28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV2.0%22%29; K-%28DevLang-CSHARP%29&RD =真
我用这段代码解决了(你认为它没问题吗?):
namespace GUIforCL2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Process _cmd;
delegate void SetTextCallback(string text);
private …Run Code Online (Sandbox Code Playgroud) 在尝试反映"listing"属性时,我得到一个InvalidOperationException,如内部异常所述.当它试图序列化ArmyListing时.
所有变量都是公开的.Checked List可以序列化.我发现大多数错误都与人们使用字典无法做到.
知道为什么看起来不可序列化吗?
//[Serializable]
public class ArmyListing
{
[XmlElement("army")]
public List<Army> listing { get; set; }
public void SerializeToXML(ArmyListing armyListing)
{
try
{
XmlSerializer serializer = new XmlSerializer(typeof(ArmyListing));
TextWriter textWriter = new StreamWriter(@"C:\Test\40k.xml");
serializer.Serialize(textWriter, armyListing);
textWriter.Close();
}
catch (Exception ex) { }
}
}
//[Serializable]
public class Army
{
//public Army();
[XmlAttribute]
[XmlArray("unit-category")]
public List<UnitCategory> settingconstraints { get; set; }
[XmlAttribute("name")]
public string armyName { get; set; }
}
//[Serializable]
public class UnitCategory
{
//public UnitCategory();
[XmlArray("unit-type")]
public List<UnitType> …Run Code Online (Sandbox Code Playgroud) 我有以下情况:带有以下变量的 powershell 脚本:
$RUBY = "C:\installing\ruby\bin\ruby.exe"
$ARGS = "C:\files\sript.rb $Arg1 $Arg2 $Arg3"
Run Code Online (Sandbox Code Playgroud)
在批处理文件中我可以写
%RUBY% %ARGS%
Run Code Online (Sandbox Code Playgroud)
它有效。
但我怎样才能在 powershell 中做到这一点?
重要的是 ruby 安装路径是可变的。
我尝试使用 Start-Process 但只启动了 ruby.exe,没有脚本。
有什么提示吗?
谢谢。
我怎样才能让我的命令在 NppExec 中运行,而不是在 cmd 中运行,而不是内置控制台,它不适用于诸如“按任意键继续”之类的事情,这仅在您按 Enter 时有效?
我在Linux环境中工作,需要为不同的工作区域加载某些模块.它们由各个文件系统目录分隔.
我想知道在输入目录时是否有一种简单的方法来运行不同的1行命令.我对使用的shell类型很灵活,但我目前正在使用C Shell.
我的C#代码通过P/Invoke调用Win32函数来使用模拟
internal class Win32Native
{
[DllImport("advapi32.dll", SetLastError = true)]
public static extern int ImpersonateLoggedOnUser(IntPtr token);
[DllImport("advapi32.dll", SetLastError = true)]
public static extern int RevertToSelf();
}
try {
var token = obtainTokenFromLogonUser();
Win32Native.ImpersonateLoggedOnUser( token );
throw new Exception(); // this is for simulation
Win32Native.RevertToSelf()
} catch( Exception e ) {
LogException( e );
throw;
}
Run Code Online (Sandbox Code Playgroud)
我也AppDomain.CurrentDomain.UnhandledException安装了处理程序,也记录了所有未处理的异常.
我确信记录异常的代码在模拟和不模拟时都能正常工作.
现在的问题是,在上面的代码中看起来好像catch没有输入,UnhandledException也没有被调用.唯一的异常跟踪是事件查看器中的条目.
如果我添加finally这样的:
try {
var token = obtainTokenFromLogonUser();
Win32Native.ImpersonateLoggedOnUser( token );
try {
throw new Exception(); …Run Code Online (Sandbox Code Playgroud) 我有一个Windows服务,下载脚本,然后运行它.
我一直在努力使我的Windows服务更安全,使它只接受签名的power-shell脚本.
我在服务器上运行了Set-ExecutionPolicy AllSigned命令,这可以在windows power shell命令提示符下运行.
但是,即使set-executionpolicy设置为restricted,我的代码仍会运行有符号和无符号脚本.
我尝试了两种方法:
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
runspace.Open();
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(@"Set-ExecutionPolicy AllSigned");
pipeline.Commands.AddScript(@"Get-ExecutionPolicy");
pipeline.Commands.AddScript(script);
Collection<PSObject> results = pipeline.Invoke();
Run Code Online (Sandbox Code Playgroud)
另一种方法:
using (PowerShell ps = PowerShell.Create())
{
ps.AddCommand("Set-ExecutionPolicy").AddArgument("Restricted");
ps.AddScript("Set-ExecutionPolicy Restricted");
ps.AddScript(script);
Collection<PSObject> results = ps.Invoke();
}
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,代码也会运行未签名的脚本.
我错过了什么吗?