C# 怎么判断是谁启动本程序的? 本帖最后由 qq183670101 于 2010-10-15 23:48:25 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的程序分为三各窗体 各对应一个 请不要叫我 分别用三个程序 那没有技术含量 感谢高手指点一二最好给出源码 我弄了很长时间 开始获取文件夹路径 是zgke 高手指点 不然我怎么也想不到 。你帮助了 我真的感谢 把注册表中改为:D:\Test.EXE /x %1然后Main方法中,依次检查args的项目,根据带"/"的项,决定该采取的操作. 用Process类。先取得当前进程。然后读取父进程 按照你说的 右键时候都不运行本程序我是这样写的 RegistryKey wenjian = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Classes\Directory\shell"); RegistryKey TestA= wenjian.CreateSubKey("用我的A打开"); RegistryKey TestB = wenjian.CreateSubKey("用我的B打开"); RegistryKey CommandA = TestA.CreateSubKey("command"); RegistryKey CommandB = TestB.CreateSubKey("command"); CommandA.SetValue("", "\"" + Application.ExecutablePath + "\"" + " /a " + "\"%1\"", RegistryValueKind.String); CommandB.SetValue("", "\"" + Application.ExecutablePath + "\"" + " /b " + "\"%1\"", RegistryValueKind.String); 请问在static void Main(string []args) { } 的里面怎么写 帮个忙 我很急的还是没有弄好。 你的思路 很正确 因为我知道QQ音乐 也是用这种方法 "F:\聊天工具\QQ\QQMusic\QQMusic.exe" /add "%1""F:\聊天工具\QQ\QQMusic\QQMusic.exe" /play "%1"这分别是右键文件夹时候 “加入 QQMusic 播放队列(&E)” "用 QQMusic 播放(&P)"对应的command值 现在请问怎么在 static void Main(string []args) { } 的里面怎么写 if (args.Length < 2) { Application.Run(new Main()); } else { switch (args[0]) { case "/a": Application.Run(new TestA()); break; case "/b": Application.Run(new TestB()); break; default: Application.Run(new Main()); break; } } 感谢 这样写 不过我需要指出 这很明了 不过有点小问题 你这样的不管怎么都只会运行main窗体 我帮你纠正一下 if (args.Length < 2) { Application.Run(new Main()); } else { string who = args[0].Substring(0, 3); switch (who) { case "/aa": Application.Run(new TestA()); break; case "/bb": Application.Run(new TestB()); break; default: Application.Run(new Main()); break; } }这样的通过 达到我所需要的目的不管怎么样感谢 jointan给出思路 不好意思 为了给用户 不带来麻烦 我要纠正一下 if (args.Length < 1) { Application.Run(new Main()); }......不然你会达不到效果的 因为我刚刚再看一遍 写错了 学习务必脚踏实地 感谢大家交流 打包的新问题 学完S1了,做阶段项目,请问下项目需求怎么写呀? 重装系统 数据库恢复 请问如何在c#中制作像msn的那种在屏幕又下角弹出的窗体啊? imageUrl如何设置 一个类的方法,客户端的两种调用方式,哪一种更符合面向对象, webForm的SqlDataAdapter的参数如何设置? HttpWebRequest 使用 WebProxy 错误 关于winform的几个问题 win8.1开发 异步、线程问题 如何确定运行某一个unit test Microsoft Visual Studio 2008中解决方案的问题
D:\Test.EXE /x %1然后Main方法中,依次检查args的项目,根据带"/"的项,决定该采取的操作.
我是这样写的
RegistryKey wenjian = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Classes\Directory\shell");
RegistryKey TestA= wenjian.CreateSubKey("用我的A打开");
RegistryKey TestB = wenjian.CreateSubKey("用我的B打开");
RegistryKey CommandA = TestA.CreateSubKey("command");
RegistryKey CommandB = TestB.CreateSubKey("command");
CommandA.SetValue("", "\"" + Application.ExecutablePath + "\"" + " /a " + "\"%1\"", RegistryValueKind.String);
CommandB.SetValue("", "\"" + Application.ExecutablePath + "\"" + " /b " + "\"%1\"", RegistryValueKind.String);
请问在
static void Main(string []args)
{
}
的里面怎么写 帮个忙 我很急的还是没有弄好。
"F:\聊天工具\QQ\QQMusic\QQMusic.exe" /play "%1"这分别是右键文件夹时候 “加入 QQMusic 播放队列(&E)” "用 QQMusic 播放(&P)"对应的command值 现在请问怎么在
static void Main(string []args)
{
}
的里面怎么写
{
Application.Run(new Main());
}
else
{
switch (args[0])
{
case "/a":
Application.Run(new TestA());
break;
case "/b":
Application.Run(new TestB());
break;
default:
Application.Run(new Main());
break;
}
}
感谢 这样写 不过我需要指出 这很明了 不过有点小问题 你这样的不管怎么都只会运行main窗体
我帮你纠正一下
if (args.Length < 2)
{
Application.Run(new Main());
}
else
{
string who = args[0].Substring(0, 3);
switch (who)
{
case "/aa":
Application.Run(new TestA());
break;
case "/bb":
Application.Run(new TestB());
break;
default:
Application.Run(new Main());
break;
}
}
这样的通过 达到我所需要的目的
不管怎么样感谢 jointan给出思路
if (args.Length < 1)
{
Application.Run(new Main());
}
......不然你会达不到效果的 因为我刚刚再看一遍 写错了 学习务必脚踏实地 感谢大家交流