关于pb调用dos命令的问题!第一个回答正确者我给全分!请各位高手帮帮忙!!!

pb001 2001-05-26 01:53:00
小弟想在pb中调用dos命令:
例如命令a.exe、但是同时想把pb中定义的字符变量s作为参数传递给a.exe
应该怎么做呢???
请详细点!我很笨的!
...全文
306 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
pb001 2001-05-28
  • 打赏
  • 举报
回复
目前最大只能加44分。
xiyahui(西西)-10
yxs2000(松子)-20
yeqiufeng(叶秋枫)-10
leonwan(啸傲)-16
差你们四位的分只有以后补上了。
「已注销」 2001-05-28
  • 打赏
  • 举报
回复
红头文件还没下来之前

要灌
leonwan 2001-05-28
  • 打赏
  • 举报
回复
终于发现楼上是假冒的。
Methodor 2001-05-27
  • 打赏
  • 举报
回复
~~呵呵
liulee 2001-05-27
  • 打赏
  • 举报
回复
呵呵,谁说的,讨论问题随便灌,要是说骂PB不好,我不允许。。。呵呵。
am2000 2001-05-27
  • 打赏
  • 举报
回复
yeqiufeng(叶秋枫)兄:听说现在出了文件,不许灌水呢!
taol 2001-05-27
  • 打赏
  • 举报
回复
还可以把DOS命令写在一个bat文件中执行也行。
「已注销」 2001-05-27
  • 打赏
  • 举报
回复
继续灌

争取上热点
liulee 2001-05-27
  • 打赏
  • 举报
回复
其实这个帖子以前有答案的,不过要找找啊...
yxs2000 2001-05-27
  • 打赏
  • 举报
回复
我有分吗?

string s,str
integer li_F
s=...//你的变量
str='a.exe '+s//命令加参数
li_F=FileOpen("run.bat",LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_F, str)
FileClose(li_F)//产生一个批处理
run("run.bat",Minimized!)//执行它
liulee 2001-05-27
  • 打赏
  • 举报
回复

呵呵,我有这么大的儿子,偶期不是老不死了.....哈哈....
pb001 2001-05-27
  • 打赏
  • 举报
回复
yeqiufeng(叶秋枫)是高手啊!
「已注销」 2001-05-26
  • 打赏
  • 举报
回复
我来给你解释一下
这是一个标准的API函数
shell32.dll不需要你关心 WIN的系统目录下会有
在PB中常常需要运行一些外部的程序或命令,并等待其执行完成后,才接下来运行剩余的代码。我们可以有两种方法:

先定义全局外部函数:

Function long ShellExecuteA (long hwnd, string lpOperation ,String lpFile, String lpParameters, String lpDirectory, Long nShowCmd) Library "shell32.dll"

Function long FindWindowA (String lpClassName , String lpWindowName ) Library "user32.dll"

Function boolean IsWindow (Long hwnd ) Library "user32.dll"

第一种方式用Run() 函数,可在窗口上建立按扭,clicked事件中包含如下Script:

ulong ll_handle

int li_loop

SetPointer(HourGlass!)

//最小化执行xxx.bat

run("xxx.bat", Minimized!)

//循环到窗口打开,根据程序执行打开所需的时间设定li_loop的循环次数,可预留长一些。

for li_loop= 1 to 10000

ll_handle = FindWindowA("tty","xxx")

yield() //函数

if ll_handle <> 0 then

exit

end if

next

//一直循环到窗口关闭

Do While isWindow(ll_handle)

Yield()

Loop

//应用执行完成

messagebox(‘ok’, ‘执行完成!’)

这种方法的缺点是不能隐藏外部应用程序窗口,只能最小化。

第二种方式用API函数,可以隐藏应用程序的窗口,但是调用bat批处理命令时需要先建立一个PIF文件指定执行完成后关闭窗口,否则窗口不会自行关闭。可在窗口上建立按扭,clicked事件中包含如下Script:

uint lu_return

ulong ll_handle

int li_loop

string ls_Path

SetPointer(HourGlass!)

lu_return = ShellExecutea(handle(parent), "open", "xxx.pif", "", ls_path, 0)

//最后一个参数改为 4,可以显示执行情况

if lu_return > 32 then

for li_loop= 1 to 10000

ll_handle = FindWindowA("tty","xxx")

yield()

if ll_handle <> 0 then

exit

end if

next

//一直循环到窗口关闭

Do While isWindow(lu_handle)

Yield()

Loop

//应用执行完成

MessageBox("ok", "执行完成!")

Else

//error

messagebox("错误", "调用外部应用程序不成功,请检查应用程序路径!")

end if



pb001 2001-05-26
  • 打赏
  • 举报
回复
to xiyahui(西西):
30分是你的了!请再等等好吗?
我想等“啸傲”回答了我的问题!

to:leonwan(啸傲)
回答了我的问题我再给你30分!

to;all
如果还有其他方法只要正确都有加分!



pb001 2001-05-26
  • 打赏
  • 举报
回复
to xiyahui(西西):
分是你的了!请再等等好吗?
我想等“啸傲”回答了我的问题!

xiyahui 2001-05-26
  • 打赏
  • 举报
回复
string ls
ls="a.exe" + 这里就看你的s是什么变量了,呵呵不是字符串的转化
run(ls)
pb001 2001-05-26
  • 打赏
  • 举报
回复
to:leonwan(啸傲)

做流方的儿子我盛感骄傲啊!
所以我就做做了!
pb001 2001-05-26
  • 打赏
  • 举报
回复
to:leonwan(啸傲)

1、能说说下面的东西的详细含义吗?
(handle(某某东西),'open',as_file_name,'','',4)

2、这个文件(shell32.dll)哪儿有呢?



leonwan 2001-05-26
  • 打赏
  • 举报
回复
你为何自称流芳之子呀。
请回答。
leonwan 2001-05-26
  • 打赏
  • 举报
回复

shellExecute的调用:
申明:
function long ShellExecuteA(long p1,string p2,string p3,string p4,string p5,int p6) library "shell32.dll";

使用:
return ShellExecuteA(handle(某某东西),'open',as_file_name,'','',4)

加载更多回复(6)

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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