How to reliable check if AutoPlay is enabled in Windows 7? - windows

I have an application that handles WM_DEVICECHANGE, and is interested in DBT_DEVICEARRIVAL.
When a new device is inserted, it needs to know if the AutoPlay dialog will pop-up. In order to find out, I am checking the values of NoDriveAutoRun and NoDriveTypeAutoRun in
SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
under HKCU and HKLM.
However, if a user goes to the "Control Panel -> AutoPlay" and unchecks "Use AutoPlay for all media and devices", then the AutoPlay is effectively disabled, but those registry values are not set. On my test box they aren't even there by default. And I believe that most users would use the Control Panel approach to disable the AutoPlay, rather than the Local Group Policy Editor.
So, my question is, what is that check mark setting (a registry value somewhere i suppose?). No matter what I try, I can't seem to (reliably) figure out if the AutoPlay is enabled or not.

It seems like an "AutoPlay" verb appears on the CD-ROM drive context menu when AutoPlay is enabled. So you could test for that.
Get an interface pointer to the shell IContextMenu for your CD-ROM drive, using IShellFolder::GetUIObjectOf
Use GetCommandString to walk through the list of verbs, looking for "AutoPlay"

Related

What Effect Does HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost\Default Registry Key Have?

I was looking into making a script which toggles a network adapter's metered or unmetered status. I found this script which allowed me to automatically toggle using registry keys. However, that script was hard coded to toggle an Ethernet connection, I wanted to toggle whichever adapter is primarily in use. I saw that in the registry folder for DefaultMediaCost, which controls metered status, there is a key called Default. I was hoping somebody could tell me what this key affects. Thank you.
I don't see why you would need a complicated script for this. Would two .reg files that switch everything to metered, or switches everything back on not do the trick?
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost]
"3G"=dword:00000002
"4G"=dword:00000002
"Default"=dword:00000002
"Ethernet"=dword:00000002
"WiFi"=dword:00000002

I am editing mouse settings in the registry but they seem to do nothing

I have made a program to change the mouse sensivity in the same way as you can do it with the Control Panel.
The changes are made in the registry, the keys at HKEY_CURRENT_USER\Control Panel\Mouse and they are in fact done (I have checked them from regedit.exe) but the mouse works as if this changes are not made. In other words, the changes do not take any effect, they only do if you use the control panel. Why do they not take effect?
Windows registry isn't something that is refreshed all the time. The changes you made will be applied after the current user (that's why it's HKEY_CURRENT_USER) logs in again, or as you said after using control panel, which will read the registry. I don't know, what language your program is written in, but you should check out this link: "https://msdn.microsoft.com/en-us/library/ms724947.aspx"
In general, tweaking registry settings directly is unsupported, especially when there's an API to tweak the setting. In this case, the API is SystemParametersInfo. In particular, you need to use the SPI_SETMOUSESPEED as the argument for the uiAction parameter.
In other words, the changes do not take any effect, they only do if you use the control panel. Why do they not take effect?
Because there's often a little more to it than setting the value in the registry. Often there is a notification that must be sent after changing the value in order to tell the all the other software on the machine to drop any cached values and replace them with the new value that's now in the registry. In many cases, the notification will be in the form of a broadcast message.
In the case of mouse driver settings, you probably need to use the SPIF_UPDATEINIFILE argument for the fWinIni parameter. You might also need to OR it with SPIF_SENDCHANGE to broadcast a WM_SETTINGCHANGE message, but I'm not sure about that.

How to implement custom UAC privilege UI?

When deleting a file in Windows Explorer (Windows 7), if admin privileges are required to delete the file, this dialog is displayed:
Is there a way to achieve this kind of effect in my app?
Currently I am launching a process 'as administrator' to perform the same sort of action (replacing a file rather than deleting it), so the user is shown the generic UAC dialog, asking:
"Do you want to allow the following program to make changes to this computer?"
Is the kind of helpful UI shown by Explorer (as opposed to the generic UAC dialog) possible in a 3rd party app?
I'm guessing no, since it would allow 3rd parties to elevate privileges in a sneaky way.
Use Button_SetElevationRequiredState to add the shield to the button. When the user pushes the button, use the COM elevation moniker to create the helper object.
The default setting on Windows 7 is for most system components to not show the UAC dialog.
If you change your setting to always prompt, you will see that clicking Continue in the Explorer dialog would create the normal UAC prompt.
As a non-system binary, your code would always prompt except at the most lenient UAC setting (never prompt.)

Firefox 10.0 disable hot keys using user.js

I'm currently working on a project where I have firefox launching in one of three modes:
normal
full - kiosk mode with only tabs, and home back and forward navigation showing.
Super - kiosk mode no tabs or anything showing just the content window (true kiosk mode)
Now due to time constraints I have implemented via pygtk rather than creating a custom Firefox extension as the requirements of the project would require a new flag adding to the command line in order to identify what mode it was to launch in. The approach I have used works beautifully, Great. . .
However the problem now is how can I disable all of the hot keys i.e. Ctrl + T, etc, without writing a extension. I am unable to use an existing extension because I need the shortcuts available when firefox is in normal mode and as firefox (for the project) can only be started via the command line programatically I would need a flag to determine weather to restrict the hot keys or not.
I was hoping to be able to achieve this using user.js which is placed programatically into the correct profiles when they are created in another bit of my application. I have tried using user.js by modifying accelKey, chromeAccess, contentAccess, generalAccessKey and menuAccessKey and setting their values to 0, which works for menu access but not for anything else.
Finally the Question
Is it possible to disable all shortcuts from user.js or can you only do it through an extension?
No, you cannot disable shortcut keys via preferences. Not all shortcut keys use the configurable Accel modifier, but even the ones that do cannot be disabled via preferences. In case you are interested, the code handling them only recognizes Meta, Alt and Ctrl as valid values, with Ctrl being the default for inputs that aren't recognized. You can try using Meta (the corresponding code is 224), it seems unmapped on PC keyboard. For anything more fancy than that you will need an extension.
I apologize if this sounds like an ad instead of an answer, it's not meant to.
If you do have time constraints and you just want to get a hold of the code you need, there is an open source kiosk project called Webconverger that has already done a lot of the heavy lifting.

How to disable cut, copy, paste, rename, etc from the Windows Registry?

I'm trying to create a software in VB.Net as my uni project to disable the following from a Windows 7 pc. I think they have to be disabled from the context menu of the Windows Registry, but instead of disabling the whole context menu, I'd like to disable the following individually.
Cut, copy, paste, rename, delete, open, print, share, create shortcut, open with, send to, new, properties.
I want to give users the option of disabling them selectively/individually via checkboxes so those options will be disabled in the right-click of a mouse.
My problem is I don't know which is the right key to disable as the registry is so huge & some keys are similiarly named.
Could anyone help me to say what are the exact key locations of the above-mentioned right-click functions in the Windows Registry or how to go about this ?
The deep flaw in the assumptions made in this question is that the context menu is configured by registry entries. It is not. Windows allows modifying a window's context menu by sending the WM_CONTEXTMENU message. Code, not config. If you are not happy with the default implementation of that message then you subclass the window procedure and provide your own message handler for that message so you can display your own context menu. This is core to the way Windows works.
Modifying the context menu of a program you didn't write is possible too but much more complicated. You use SetWindowsHookEx() to inject a DLL into the other process. You cannot write a DLL like that in VB.NET, it requires native code. Because that process won't have the CLR loaded to run your managed code.

Resources