check if UAC is enabled with VB6 - vb6

is it possible to check if UAC is enabled with VB6 on win7 and vista?
i know it has to do with reading a value in the registry, i have see .net versions, but i need a vb6 sample code
thanks

DevX.com has an example of how to read the registry using VB6.
You'll have to add this constant: Const HKEY_LOCAL_MACHINE = &H80000002...it's missing from the sample.
You'll want to read the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System key's EnableLUA value. 1 == enabled.
There's also a decent example at freevbcode.com.

Related

How to programmatically set registry setting to prevent Outlook from removing the VSTO Addin

Hi is there a way to programatically set the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Resiliency\DoNotDisableAddinList\
with DWORD= 1
As I learned from this posting (among many others) this prevents Outlook from removing my Addin from Outlook for being slow. Yes, it would be better to design the AddIn for being faster. But as it needs to connect service on the internet this will be hard to achieve. BTW: I have this problem also with many other Addins.
You need to use .Net base class libraries to get the job done, the RegistryKey class represents a key-level node in the Windows registry. See How to: Create a Key In the Registry (Visual C#) for more information.
Read more about possible windows registry keys and their values in the Add-ins are user re-enabled after being disabled by Office programs article.

How can I tell if local powershell is enabled/disabled from the registry on Windows 2008 R2?

I was wondering if someone could help. I'm looking for the registry key indicting if powershell is enabled or disabled.
I checked the keys and values in HKLM\SOFTWARE\Wow6432Node\Microsoft\PowerShell, but didn't see any difference between enabled and disabled states.
Where else could it be ?

How to change the spool/direct print setting via code?

I need to change the setting in the print properties that specifies either: 1. "Spool print documents..." or 2. "Print directly to the printer."
In this answer J... indicates that this can be done using the PrintQueue Class. How?
MSDN PrintQueue.isDirect (ReadOnly Property) says this: "This property can be set only
through the Windows common print dialog."
I assume that applies specifically to .net and may not be true in the absolute sense. So how to change the spool/print direct setting via code?
From comment of J...
Quoting from: Windows Spooler Registry
Various printer options can be set via the windows registry. Each
installed printer has a subkey in the following Registry path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\
Under this there is a attributes bitmap, in the value Attributes :
REG_DWORD 0002 (0x0002) Direct: Document to be sent directly to the
printer.
The spooler service might need to be restarted, for the changes to
take effect.
Note that this registry value contains multiple attributes. See Windows Spooler Registry for more details.
Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. Modify the registry at your own risk.

How to run an Application on windows start up in win32 API using visual c++

I have a Window (win32 API) Application in visual c++. I am not using MFC. I have to run my application on windows start up. I am using windows 7 and visual studio 2008. Can any one help me out in achieving the above task? Thanks in advance.
Here's some example code:
HKEY hkey = NULL;
RegCreateKey(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", &hkey);
RegSetValueEx(hkey, L"myapp", 0, REG_SZ , (BYTE*)path, (wcslen(path)+1)*2);
The most straightforward way is to create a registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
(Insert the code into your installation program to add the key.)
If you create it under HKEY_LOCAL_MACHINE, it will apply to all users of the machine. If you create it under HKEY_CURRENT_USER, then the program will run automatically upon startup only for that user.
Don't know about Win32 but how about a simple shortcut to your program:
C:\Documents and Settings\\Start
Menu\Programs\Startup
(or use All Users instead of USER)
Just add it to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run key int he registry.
Look at autoruns by SysInternals (now Microsoft). It will show you the many ways a process can be started by Windows. You will want to check out the Logon tab which shows several file and registry settings that can enable you to start stuff on Logon. Services and Drivers start on system startup (don't require a logon). Bootexecute allows you to run stuff at boot time which is probably not what you want.
The rest of the tabs show you how to hook into various other system processes to load your code. It's no wonder Windows is ripe for malware authors especially if you run as root.
If you create the registry entry under HKEY_LOCAL_MACHINE, the application startup is forced on all users on the local machine. Write entries below HKEY_CURRENT_USER key to target only the current logged(active) user while this application is launched.
CString csPath ="your path";
HRESULT hres = RegCreateKey(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hkey);
hres = RegSetValueEx(hkey, L"your app", 0, REG_SZ , (BYTE*)csPath.GetBuffer(), (wcslen(csPath)+1)*2);

How to turn off popup blocker through code in Watin?

I am facing trouble in turning the popup blocker off through watin code. Could anyone please help me in knowing how to turn off the popup blocker of IE through watin? Is there any way to turn off the popup blocker of tool bars (like google, yahoo or msn) if any of them are installed in IE? Thanks for your help in advance.
You can use .NET to change the registry keys for IE. See http://support.microsoft.com/kb/843016 for more information on the specific keys.
All:
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_WEBOC_POPUPMANAGEMENT
Value = 0 for Off
Value = 1 for On
Per Zone:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\[0-4]\1809
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\[0-4]\1809
Value = 0 for Enabled
Value = 3 for Disabled
Per Site:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows\Allow
Create subkey with domain name and binary data.
Here is a code example of writing the registry keys through .NET to get a site into a trusted zone, which allowed WatiN to be able to download a file:
Programmatically add trusted sites to Internet Explorer
You can't disable this with WatiN, you could however use UIAutomation to do it.

Resources