通过 shellexecute 从 delphi 运行 ruby 脚本
我编写了一个小 ruby 脚本,让我可以通过调用它以及一些命令行参数来发送电子邮件。
在命令行中,这是有效的:
ruby.exe mail_it.rb fromaddr="[email protected]" tolist="[email protected]"
但是尽我所能,我无法让它在 Delphi 2007 for Win32 中工作。这是最新的尝试:
procedure TForm1.Button1Click(Sender: TObject);
var
params: string;
begin
params:= 'mail_it.rb fromaddr="[email protected]" tolist="[email protected]"';
caption:= IntToStr(ShellExecute(Form1.Handle, nil, PChar('ruby.exe'), PChar(params), nil, SW_SHOW));
end;
我尝试使用“open”作为 ShellExecute 中的第二个参数,但没有帮助。 ShellExecute 本身返回 42,据我在其他网站上发现的内容可知,这意味着“没有错误”。
I've written a little ruby script that lets me send emails by calling it along with some command line parameters.
At the command line, this works:
ruby.exe mail_it.rb fromaddr="[email protected]" tolist="[email protected]"
But try as I may, I can't get it to work in Delphi 2007 for Win32. Here's the latest attempt:
procedure TForm1.Button1Click(Sender: TObject);
var
params: string;
begin
params:= 'mail_it.rb fromaddr="[email protected]" tolist="[email protected]"';
caption:= IntToStr(ShellExecute(Form1.Handle, nil, PChar('ruby.exe'), PChar(params), nil, SW_SHOW));
end;
I've tried using 'open' as the second param in ShellExecute, but it doesn't help. ShellExecute itself returns 42, which as far as I can tell from what I've found on other websites means "no error".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
我没有安装 ruby,但这对我用编辑器启动 .pas 文件很有用。只要您有与 .rb 文件关联的 ruby.exe,它就应该可以工作。
-大学教师
try this:
i don't have ruby installed, but this works for me starting a .pas file with the editor. as long as you have ruby.exe associated with .rb files, it should work.
-don
这是有效的最小代码:
我不需要 mail_it.rb 的完整路径,也不需要“open”,但我确实需要“.rb”。
Here's the minimal code that works:
I did NOT need the full path to mail_it.rb, nor the 'open', but I DID need the '.rb'.