一个简单问题,请求帮助!

lmdhit 2003-07-05 10:04:24
在C#中编程实现SHELL,用WinExec来调用系统的程序,有用过的吗?能给点建议吗?
有代码高分相送!
最好最路径问题讨论讨论,因为我的程序要在别的机器也也能运行,路径的可移植性是个主要问题!
...全文
31 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
lmdhit 2003-07-11
  • 打赏
  • 举报
回复
那就是说shellExecute,winExec,没什么用了啊,。用process.start()怎么控制窗口的大小啊!
请教!另外[DllImport("shell32.dll", EntryPoint="ShellExecute")]
这个是干什么的?
TheAres 2003-07-11
  • 打赏
  • 举报
回复
不用调用shellExecute,process.Start就好。这个就是对shellExecute的封装。
lmdhit 2003-07-11
  • 打赏
  • 举报
回复
re!!
能把shellExecute的使用方法代码告诉我吗?这个和上面的process.Start()有什么区别!
能解释一下吗?
ArLi2003 2003-07-08
  • 打赏
  • 举报
回复
ShellExecute 的原形是:

ShellExecute(句柄,操作,文件名,参数,目录,窗口大小)

比如上面的

ShellExecute(this.Handle.ToInt32(),"open","notepad.exe",null,null,SW_MAXIMIZE);

是最大化打开一个记事本
ArLi2003 2003-07-08
  • 打赏
  • 举报
回复
using System.Runtime.InteropServices;

[DllImport("shell32.dll", EntryPoint="ShellExecute")]
public static extern int ShellExecute (int hwnd,string lpOperation,string lpFile,string lpParameters,string lpDirectory,int nShowCmd);

public const int SW_MAXIMIZE = 3; //最大化
public const int SW_MINIMIZE = 6; //最小化
public const int SW_SHOWNORMAL = 1; //通常
public const int SW_HIDE = 0; //隐藏

private void button1_Click(object sender, System.EventArgs e) {
ShellExecute(this.Handle.ToInt32(),"open","notepad.exe",null,null,SW_MAXIMIZE);
}

/*
u can download API_Explorer from:

http://zpcity.com/arli/

*/
lmdhit 2003-07-07
  • 打赏
  • 举报
回复
我想调用后的程序能够控制它的窗体大小啊!
比如最大化启动或者是最小化启动啊!
lmdhit 2003-07-07
  • 打赏
  • 举报
回复
re
ArLi2003 2003-07-05
  • 打赏
  • 举报
回复
wait? see msdn

路径的可移植性, u can try Path.Combine(path1,path2)
lmdhit 2003-07-05
  • 打赏
  • 举报
回复
没有人愿意告诉我吗?
lmdhit 2003-07-05
  • 打赏
  • 举报
回复
I just have a try.
using the System.Diagnostics.Process.
for example:
Process.Start("regedit.exe");
but I don't know your program main
p.StartInfo.RedirectStandardOutput=false; //p is a process?

p.StartInfo.FileName="C:\\Test.txt"; //we should give the absolute path ???

p.StartInfo.UseShellExecute=true; //what????
p.Start(); //begin?
p.WaitForExit(); //wait?
p.Dispose(); //what?
saucer 2003-07-05
  • 打赏
  • 举报
回复
1. you can always use Win32 API with P/Invoke

[DllImport("Shell32.dll")]
public static extern int ShellExecute(int hwnd, string lpOperation, string
lpFile, string lpParameters, string lpDirectory, int nShowCmd);

2. use System.Diagnostics.Process class, for example

System.Diagnostics.Process p = new Process();

p.StartInfo.RedirectStandardOutput=false;

p.StartInfo.FileName="C:\\Test.txt";

p.StartInfo.UseShellExecute=true;
p.Start();
p.WaitForExit();
p.Dispose();

110,568

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧