Solved

bin huwairib. only

Posted on 1998-06-04
6
149 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Date Picker 64 bit 32 bit issue 12 49
Getting warning: You are about to delete 1 row(s) 9 43
Access Object Property from VBA Module in Excel 2010 2 27
vbModal 12 35
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

920 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

11 Experts available now in Live!

Get 1:1 Help Now