VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code removes the File Menu from Internet explorer.The same can be restored by the code.

by Vishal V. Kulkarni (6 Submissions)
Category: Registry
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 26th February 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code removes the File Menu from Internet explorer.The same can be restored by the code.

API Declarations


'For any such querries please do not
'hesitate to contact [email protected]
'******Requirements.********
'Take a seperate module and paste the following code in it.
'***************************
Global Const HKEY_CURRENT_USER As Long = &H80000001
Private Const KEY_ALL_ACCESS = &H3F
Private Const REG_OPTION_NON_VOLATILE = 0
Global Const REG_SZ As Long = 1
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, pdwDisposition As Long) As Long
Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hkey As Long, ByVal lpSubKey As String) As Long
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 RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hkey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long
Private Function SetValueEx(ByVal hkey As Long, sValueName As String, lType As Long, vValue As Variant) As Long
Dim nValue As Long
Dim sValue As String
Select Case lType
Case REG_SZ
sValue = vValue & Chr$(0)
SetValueEx = RegSetValueExString(hkey, sValueName, 0&, lType, sValue, Len(sValue))
Case REG_DWORD
nValue = vValue
SetValueEx = RegSetValueExLong(hkey, sValueName, 0&, lType, nValue, 4)
End Select
End Function
Public Sub CreateNewKey(sNewKeyName As String, lPredefinedKey As Long)
Dim hkey As Long
Dim r As Long
r = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hkey, r)
Call RegCloseKey(hkey)
End Sub
Public Sub SetKeyValue(sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long)
Dim r As Long
Dim hkey As Long
r = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, KEY_ALL_ACCESS, hkey)
r = SetValueEx(hkey, sValueName, lValueType, vValueSetting)
Call RegCloseKey(hkey)
End Sub
Public Function Delete(hkey As Long, ItemKey As String, ValueName As String) As Boolean
Dim phkResult As Long, retval As Long, retval1 As Long
If ItemKey <> Empty Then
If ValueName <> Empty Then
retval = RegOpenKeyEx(hkey, ItemKey, 0&, KEY_ALL_ACCESS, phkResult)
If retval = 0 Then
retval = RegDeleteValue(phkResult, ValueName)
retval1 = RegCloseKey(phkResult)
End If
Else
retval = RegDeleteKey(hkey, ItemKey)
End If
Delete = (retval = 0)
End If
End Function


Rate This code removes the File Menu from Internet explorer.The same can be restored by the code.



'hesitate to contact [email protected]
'*********Requirements.*********
'Take a VB form (form1 by default)
'Take two command buttons (command1,command2 by default).
'********************************
'Author:Vishal V. Kulkarni
'Task:To remove file menu from internet explorer

Private Sub Command1_Click()
    'Calling function CreateNewKey  to create a new key and SetKeyValue  to set the new value
    CreateNewKey "software\microsoft\windows\currentversion\policies\explorer\", HKEY_CURRENT_USER
    SetKeyValue "software\microsoft\windows\currentversion\policies\explorer\", "NoFileMenu", 1, REG_SZ
End Sub
Private Sub Command2_Click()
    'Ok its enough now we want to restore the menu
    Dim s
    s = Delete(HKEY_CURRENT_USER, "software\microsoft\windows\currentversion\policies\explorer\", "NoFileMenu")
End Sub



Download this snippet    Add to My Saved Code

This code removes the File Menu from Internet explorer.The same can be restored by the code. Comments

No comments have been posted about This code removes the File Menu from Internet explorer.The same can be restored by the code.. Why not be the first to post a comment about This code removes the File Menu from Internet explorer.The same can be restored by the code..

Post your comment

Subject:
Message:
0/1000 characters