To specify the default location where downloaded files from Internet explorer are saved , we need to set the default location (directory path in registry). The registry key location is [HKCU\Software\Microsoft\Internet Explorer]
Here is the code sample in VB 6.0 [VB 6.0 Code Starts]
' -- Declaration and API calls for writing to registry
Private Const HKEY_CURRENT_USER = &H80000001 ‘Create Registry Key Private Declare Function RegCreateKey Lib “advapi32.dll” Alias “RegCreateKeyA” (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long ‘Store a 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 ‘Close Registry Key
Private Declare Function RegCloseKey Lib “advapi32.dll” (ByVal hKey As Long) As Long
‘– Method to set registry value
‘ Save values in registry Private Sub SaveValue(hKey As Long, strPath As String, strValue As String, strData As String) Dim ret ‘Create a new key RegCreateKey hKey, strPath, ret ‘Save a string to the key RegSetValueEx ret, strValue, 0, REG_SZ, ByVal strData, Len(strData) ‘close the key RegCloseKey ret
End Sub
‘—-Method call to set default location in registry
SaveValue HKEY_CURRENT_USER, “Software\Microsoft\Internet Explorer”, “Download Directory”, “C:\MyDownloads”
[VB 6.0 Code Ends]