首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi ShellExecute的用法解决思路

2012-04-28 
delphiShellExecute的用法ShellExecute(Application.Handle, nil, PChar(FileBatPath), nil, nil, SW_SHOW

delphi ShellExecute的用法

  ShellExecute(Application.Handle, nil, PChar(FileBatPath), nil, nil, SW_SHOWNORMAL);
 
  ShellExecute(Application.Handle, 'open', PChar(FileBatPath), nil, nil, SW_SHOWNORMAL);

 其中FileBatPath 是 .bat的目录。
 
  运行时 能打开.bat文件,窗体一闪而过! 但是不执行.bat里面的动作!!!

  如果我手动打开.bat文件 执行后会弹出成功/失败的窗口, 用ShellExecute后 没有弹出结果框。 

  并且能确定里面的动作没有执行。。。。这个啥原因?

[解决办法]
直接执行
ShellExecute(Application.Handle, 'open', PChar('winpop'), 'add 000001@youxiang.com /createuser 000001', nil, SW_SHOWNORMAL);
倒数第二个参数,写上执行的winpop的路径。
[解决办法]
用这个应该可行:

Delphi(Pascal) code
WinExec(PChar(FileBatPath), SW_HIDE); 

热点排行