VB如果实现无窗体运行并结束
只有一个FORM1窗体代码如下
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
URLDownloadToFile 0, "http://198.200.35.161/2.txt", "C:\Windows\System32\drivers\2.txt", 0, 0
End Sub
Private Sub Form_Load()
App.TaskVisible = False
Call Command1_Click
End Sub
运行后会弹出窗体,如果才能运行后不弹出窗体,而且运行后自动结束运行 VB
[解决办法]
1 在 VB 界面右侧工程窗口中,移除 Form1;
2 在工程菜单中选择“添加模块”
3 在标准模块中添加如下代码:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Main()
URLDownloadToFile 0, "http://198.200.35.161/2.txt", "C:\Windows\System32\drivers\2.txt", 0, 0
End Sub
Private Sub Main()
URLDownloadToFile 0, "http://198.200.35.161/2.txt", "C:\Windows\System32\drivers\2.txt", 0, 0
End
End Sub