Rob Kraft's Software Development Blog

Software Development Insights

Posts Tagged ‘registry’

Reading from the registry with Silverlight.

Posted by robkraft on May 20, 2010

Yes, you can read from the registry of the local machine using a Silverlight application.  This is subject to these qualifications:

1)     The Silverlight App must be running out-of-browser.  This is necessary so that you can run the Silverlight App with elevated permissions.

2)     The Silverlight App must be running with Elevated Permissions.  This is necessary so that you can access the COM Interop.

3)     The COM Interop Automation Factory must be available.  Honestly, if you are running out of browser with elevated permission I don’t know why it would not be available.

4)     You must be running Silverlight 4.

To do this for yourself:

1)     Create a new Silverlight Application in Visual Studio 2010

2)     Open the Project Properties, select the Silverlight tab, and check the box for “Enable running application out of the browser”.

3)     Click on the “Out-of-Browser Settings” button and check the box for “Require elevated trust when running outside the browser”.

4)     Place a simple button in the Grid your MainPage.xaml.  Use the default name button1.

5)     Paste this code:

          private void button1_Click(object sender, RoutedEventArgs e)

          {

              if (App.Current.IsRunningOutOfBrowser)

                   MessageBox.Show(“Running Out of Browser!”);

              if (App.Current.HasElevatedPermissions)

                   MessageBox.Show(“Has elevated Perms!”);

              if (AutomationFactory.IsAvailable)

                   MessageBox.Show(“Automation Factory is Available!”);

              dynamic WshShell = AutomationFactory.CreateObject(“WScript.Shell”);

               MessageBox.Show(WshShell.RegRead(@”HKLM\SOFTWARE\Microsoft\Silverlight\Version”));

          }

6)     Run the app, right-click on the form and choose “Install ..appname… onto this computer…”

7)     Click the button on the “out-of-browser” version of the app.  Hopefully you receive all the expected values.

Advertisements

Posted in Visual Studio 2010 | Tagged: , | Leave a Comment »

Free program to allow blocked outlook attachments

Posted by robkraft on December 25, 2007

I wrote my first WPF program yesterday.  The simple program allows you to unblock attachments in Microsoft Outlook.  Because this program relies on Microsoft’s new WPF technology, you must install the .Net 3.5 framework on your computer to run it.

The program gives you a list of file extensions from which you can choose for Microsoft Outlook to allow.  The program reads and writes to the registry of the local computer.  The program works for Outlook verions 9,10,11, and 12 (Outlook 2000 through 2007).

The program is based on http://support.microsoft.com/kb/829982.  It helps you get past this message “Outlook blocked access to the following potentially unsafe attachments”.

Please be aware that files with these extensions are blocked to prevent harm to your computer.  If you need to unblock an extension in order to receive a file you trust, I recommend you re-block that extension after you have received the file.  You will need to stop and restart Outlook after making a change.

Note that the settings on your Exchange server may still prevent you from receiving the file in Outlook.

My program can be downloaded from this page: http://www.kraftsoftware.com/FreeStuff/tabid/57/Default.aspx

I am working on a version that does not require .Net 3.5 (wpf).  It will just require .Net 2.0.

Posted in Outlook Utility, Visual Studio 2008 | Tagged: , , , , | 1 Comment »