Link to home
Start Free TrialLog in
Avatar of Yogesh_Agarwal
Yogesh_Agarwal

asked on

Small Error -> vb6 Code to VB.net

Here i am getting error. "As Any" cannot be used in Declare statements. Please clear all errors in this code..
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, 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
 
Const KEY_WRITE = &H20006
Const REG_SZ = 1
Const KEY_HKCU = &H80000001 'long value for HKEY_CURRENT_USER
 
Sub SetRegistryValue(value As String)
    Dim handle As Long
    Dim strValue As String
    Dim retVal As Long
    
    ' Open the key, exit if not found
    If RegOpenKeyEx(KEY_HKCU, "Software\Microsoft\Internet Explorer\Main", 0, KEY_WRITE, handle) Then
        Exit Sub
    End If
 
    strValue = value
    retVal = RegSetValueEx(handle, "Display Inline Images", 0, REG_SZ, ByVal strValue, Len(strValue))
        
    ' Close the key and signal success
    RegCloseKey handle
End Sub
 
Public Function ShowImages()
    SetRegistryValue ("yes")
End Function
 
Public Function HideImages()
    SetRegistryValue ("no")
End Function

Open in new window

Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

You don't need to use API's to work with registry. You have classes included in Visual Studio to help you on that.
 
Check this examples:
http://www.codeproject.com/KB/vb/registry_with_vb.aspx  
http://www.devasp.net/net/articles/display/155.html
http://www.wwwcoder.com/main/parentid/263/site/2281/68/default.aspx
Avatar of Yogesh_Agarwal
Yogesh_Agarwal

ASKER

but this code helps me to switch off loading of images in webbrowser control (IE) as i don know how to do it programatically. I want to change registry(switch of loading of image in IE programatically).. cud u please help me?
ASKER CERTIFIED SOLUTION
Avatar of Aleksei_Malkov
Aleksei_Malkov
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
change it for a String in this case.
Right...if you want to keep the old API approach then change all Long to Integer, and replace As Any with the appropriate Type.
great..