shellexecute()的用法

randee_luo 2011-06-01 03:20:43
 str_url:='http://211.155.25.158:8090/Submit.asp?cmp_name=public&user_name=1231&user_pass=123456&rec_mobile=13712536345&msg_content=各位。你们好!';
ShellExecute(Handle,'open','explorer.exe',PChar(str_url),nil, SW_SHOWNORMAL);

上面的url用shellexecute打不开。。 但我换成http://www.baidu.com就能打开。。不知道为什么。
报的错的:“路径’各位。你们好!‘不存在,或者是无效目录。”

无论我把上面的“各位。你们好!”换成什么报的错都是一样。 无非就是把各位。你们好这几个字换了而已。。

请帮我个忙。。
...全文
304 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyanfangyanli 2011-06-04
  • 打赏
  • 举报
回复
看看!!!!!!
lyhoo163 2011-06-04
  • 打赏
  • 举报
回复
关注。
phyf_Anlymi 2011-06-03
  • 打赏
  • 举报
回复
学习了!
randee_luo 2011-06-03
  • 打赏
  • 举报
回复
哈哈。 谢谢各位了。 已经成功了。 我用的也就是先转换成http格式,然后把explorer.exe改为nil
chu_czx444 2011-06-02
  • 打赏
  • 举报
回复
试试 ShellExecute(Handle,'open','explorer.exe',PChar(str_url),PChar(str_url), SW_SHOWNORMAL);
弘石 2011-06-02
  • 打赏
  • 举报
回复
你要是不指定explorer.exe,就不会有那个问题了
cicidodo 2011-06-02
  • 打赏
  • 举报
回复
ShellExecute(Application.Handle,'open',PChar(str_url),nil,nil, SW_SHOWNORMAL);
randee_luo 2011-06-01
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 lahcs 的回复:]
不知道是不是这个URL编码问题...
jxlhc09测试成功了么?
[/Quote] 貌似还是不行。 这个函数是起到了效果。。但是结果还是一样。 报同样的错。
randee_luo 2011-06-01
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 lahcs 的回复:]
不知道是不是这个URL编码问题...
jxlhc09测试成功了么?
[/Quote]
刚才有事去了。 现在就试试去
dropme 2011-06-01
  • 打赏
  • 举报
回复
明显是没编码的问题呀,url里有中文字符,这样打不开的,引用HttpApp单元,然后:
ShellExecute(Handle,'open','explore.exe',PChar(HttpEncode(AnsiString(str_url))),nil, SW_SHOWNORMAL);
lahcs 2011-06-01
  • 打赏
  • 举报
回复
不知道是不是这个URL编码问题...
jxlhc09测试成功了么?
lahcs 2011-06-01
  • 打赏
  • 举报
回复
httpApp单元 的转换函数 HTTPEncode

function HTTPEncode(const AStr: String): String;
// The NoConversion set contains characters as specificed in RFC 1738 and
// should not be modified unless the standard changes.
const
NoConversion = ['A'..'Z','a'..'z','*','@','.','_','-',
'0'..'9','$','!','''','(',')'];
var
Sp, Rp: PChar;
begin
SetLength(Result, Length(AStr) * 3);
Sp := PChar(AStr);
Rp := PChar(Result);
while Sp^ <> #0 do
begin
if Sp^ in NoConversion then
Rp^ := Sp^
else
if Sp^ = ' ' then
Rp^ := '+'
else
begin
FormatBuf(Rp^, 3, '%%%.2x', 6, [Ord(Sp^)]);
Inc(Rp,2);
end;
Inc(Rp);
Inc(Sp);
end;
SetLength(Result, Rp - PChar(Result));
end;
弘石 2011-06-01
  • 打赏
  • 举报
回复
httpApp单元里有转换函数urlencode吧
lahcs 2011-06-01
  • 打赏
  • 举报
回复
其实就是URL中常用的编码转换

http://baike.baidu.com/view/204662.htm
randee_luo 2011-06-01
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 lahcs 的回复:]
试试把中文转换成URL编码

Delphi(Pascal) code

function URLEncode(const S: string):string;
var
Idx: Integer; // loops thru characters in string
begin
Result := '';
for Idx := 1 to Length(S) do
……
[/Quote]
能给我解释下这段code吗? 看不懂你for后面的语句哟
DELPHI2049 2011-06-01
  • 打赏
  • 举报
回复
ShellExecute(Handle,'open','iexplore.exe',PChar(str_url),nil, SW_SHOWNORMAL);
lahcs 2011-06-01
  • 打赏
  • 举报
回复
试试把中文转换成URL编码

function URLEncode(const S: string):string;
var
Idx: Integer; // loops thru characters in string
begin
Result := '';
for Idx := 1 to Length(S) do
begin
case S[Idx] of
'A'..'Z', 'a'..'z', '0'..'9', '-', '_', '.':
Result := Result + S[Idx];
' ':
{ if InQueryString then
Result := Result + '+'
else }
Result := Result + '%20';
else
Result := Result + '%' + SysUtils.IntToHex(Ord(S[Idx]), 2);
end;
end;
end;

//转换完成后的URL变为
//http://211.155.25.158:8090/Submit.asp?cmp_name=public&user_name=1231&user_pass=123456&rec_mobile=13712536345&msg_content=%B8%F7%CE%BB%A1%A3%C4%E3%C3%C7%BA%C3%A3%A1


弘石 2011-06-01
  • 打赏
  • 举报
回复
恩,应该也能正常打开
你把url参数用双引号括起来就行了
randee_luo 2011-06-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 bdmh 的回复:]
引用 2 楼 jxlhc09 的回复:
后者是用默认的explorer打开的。 应该不是这个原因。。 要不然我百度也应该是打不开呀。

如果你不指定'explorer',会默认,你指定了'explorer',就会用资源管理器打开
[/Quote]
我就是用的这个。 然后用的360打开的百度 因为我默认的是360浏览器
lahcs 2011-06-01
  • 打赏
  • 举报
回复

ShellExecute(Handle,'open',PChar(str_url),nil,nil, SW_SHOWNORMAL);


直接这样默认就好
加载更多回复(3)

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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