Solved

bin huwairib. only

Posted on 1998-06-04
6
146 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now