Solved

bin huwairib. only

Posted on 1998-06-04
6
155 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

820 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