Solved

bin huwairib. only

Posted on 1998-06-04
6
153 Views
Last Modified: 2010-05-03
from josmic may 9 98 question to disable right mouse click
I owe you points, here they are. but I cant get it to work, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
how does this work, where does it go within vb5, this
line and the next 3 wont compile. thank you.
0
Comment
Question by:josmic
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 100 total points
ID: 1462586
Josmic,

Sorry because of my delayed answer, I was busy with other matters recently.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer is a registry location and you can't use it directly within VB, so you have to write a sub/function to update this location with the specific value, anyway don't bother your self about the function here it is.

1- Add form1 to project1.
2- Add command1, command2, command3 and command4 to form1.
3- Paste the following code:

Private Const HKEY_CURRENT_USER = &H80000001
Private Const REG_DWORD = 4&
Private Const KEY_ALL_ACCESS = &H3F

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 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

Function SetValueEx(KeyName, ValueName As String, Value As Variant) As Long
 Dim hKey As Long
 Dim lValue As Long
   
 lValue = Value
 Call RegOpenKeyEx(HKEY_CURRENT_USER, KeyName, 0, KEY_ALL_ACCESS, hKey)
 SetValueEx = RegSetValueExLong(hKey, ValueName, 0, REG_DWORD, lValue, 4)
End Function

Private Sub Command1_Click()
 'To Enable the Desktop/Explorer's context menu
 Call SetValueEx("Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoViewContextMenu", 1)
End Sub

Private Sub Command2_Click()
 'To Disable the Desktop/Explorer's context menu
 Call SetValueEx("Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoViewContextMenu", 0)
End Sub

Private Sub Command3_Click()
 'To Enable the Start/Tray's context menu
 Call SetValueEx("Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoTrayContextMenu", 1)
End Sub

Private Sub Command4_Click()
 'To Disable the Start/Tray's context menu
 Call SetValueEx("Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoTrayContextMenu", 0)
End Sub

NOTE: Disabling the context menu will be effected immediately but to enable it you must restart windows to take the effect.


Best regards
Bin Huwairib
0
 

Author Comment

by:josmic
ID: 1462587
this did not work, any suggestions. to clarify, is this to
enable/disable the right/mouse click, and the start button
in the taskbar?
0
 
LVL 5

Expert Comment

by:bin_huwairib
ID: 1462588
josmic,

The code above is doing the following:
1- Enable/Disable right-mouse click on the Desktop window.
2- Enable/Disable right-mouse click on the Explorer window.
3- Enable/Disable right-mouse click on the Taskbar.
4- Enable/Disable right-mouse click on the Start button.

If you face any kind of error please post it, and don't hesitate to ask if you need more clarification.

Bin Huwairib
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:josmic
ID: 1462589
bin. O.K.,if only I could get this to work.
Ive done exactly as you said, and again on a new project.
I get no errors, but the right mouse click still works
in all 4 places. Im using Vb5 and win98.? thank you.
0
 
LVL 5

Expert Comment

by:bin_huwairib
ID: 1462590
I'm sorry josmic, I didn't test it on Windows98 yet.

It is working fine with Windows95 and WindowsNT.

Bin Huwairib
0
 

Author Comment

by:josmic
ID: 1462591
bin, thanks for the help. I will repost this question. I
am going to give you these points anyway.
1) Since your online now perhaps you know how to disable the start button (bottom left on the taskbar)  -without-  disabling the taskbar or hidding the taskbar. I dont care if the start button is visible or not.
2) or im having problems with a webbrowser control. my back and forw buttons dont remember more than the verylast or the verynext
Im using webbrowser.GoBack and frw, I've seen somewhere in here
a refference to code with history list box  etc instead of
back and forw and I think you answered it.?

Ive been picking up code here and have not run into a win98
problem yet. Again thanks.





0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 115
Concatenate 2 userform comboboxes to a userform text box 4 64
Child Form in front 4 47
Error with a code discussed on this page 5 16
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question