作者siaujan (...)
看板Visual_Basic
标题[.NET] ShellExecute() 使用方法?
时间Sun May 20 17:07:02 2007
我希望用ComboBox选单选到一个项目时,
就开启浏览器连结到该网页
我爬了文,看到ShellExecute()这个方法,
不过我用的时候会出现以下PInvoke的错误..
http://www.sendspace.com/file/oabzlp
请问是我哪里写错了吗?
原本想说直接呼叫不行,所以我用MSDN查到的方法,
设定Long变数来呼叫(就是下面button的写法),
结果还是不行,会跳出一样的错误讯息
================ 程式码 ================
Public Class Form1
Dim cbb2Arr() = {"青文", "东立"}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
cbb2.Items.AddRange(cbb2Arr)
End Sub
Private Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub cbb2_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbb2.SelectedIndexChanged
If cbb2.SelectedItem = "青文" Then
ShellExecute(0, "open", "
http://www.ching-win.com.tw/", 0, 0, 1)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim r As Long
r = ShellExecute(0, "open", "http://www.ching-win.com.tw/", 0, 0, 1)
End Sub
End Class
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.113.3.164
※ 编辑: siaujan 来自: 59.113.3.164 (05/21 22:39)