Wednesday, December 29, 2010

PS3 Media Server streaming & transcoding to XBMC for Xbox

PS3 Media Server is an interesting alternative to VLC streaming, as it allows you better control over the media being played, it does allow you to choose what to play and even to navigate the stream, although it won’t allow you to navigate transcoded streams.

Again, this guide is meant to be more of a playground test showing how to get it working with XBMC, this must be the second time I tried it and I know it can be frustrating due to the number of options you need to change to make it work for XBMC for Xbox.
This is what I’ve used:


PS3 Media Server


The software comes with a configuration file to support XBMC, in which I’ve changed a few settings to better suit XBMC for Xbox. Edit “%ProgramFiles%\PS3 Media Server\renderers\xbmc.conf” (or %ProgramFiles(x86)% if you have an x64 OS) and change the following options:
  • MaxVideoWidth=720 
  • MaxVideoHeight=576
  • TranscodeExtensions=mp4
  • StreamExtensions=mkv,hdmov,hdm,flac,fla,dts,ogg,asf,asx,m2v,avi
MaxVideoWidth/Height allow to configure the size of the transcoded (output) video, again these values are not set in stone, change to suit your case, just like VLC streaming, go as high as XBMC4Xbox can play and probably (unlike I did) use resolutions that match your display and the source video – e.g. for a 720p display (1280x720) the screen has a 1.77 ratio, in my defence it was late and tired and copied the wrong settings from a website Smile 720x576 is the usual PAL resolution, but that’s a 1.25 ratio. Anyways, I’m not going to redo all the screenshots and everything so I’ll leave that to you as homework.

Next I chose to always transcode the .mp4 extension by adding it to the TranscodeExtensions (that will make the video appear in the list on XBMC side ready to be played transcoded, rather than go into the #TRANSCODE# menu, thought I show case it in here). I’v also added the avi extensions to the StreamExtensions that way you can play it (and navigate the stream) from XBMC. As I mentioned earlier you cannot navigate an MEncoder transcoded stream (I believe PS3 Media Server has a note on that somewhere).

Now you can proceed at starting PS3 Media Server and start the configuration in the GUI interface. You can change a few more settings that I will mention, but I will keep it at minimum for brevity sake.
Add your media folders into the Navigation/Share Settings tab. If you don’t it will share all disks on your machine – I just added one folder for this test where I have the test video.


In Transcoding tab, I’ve changed a few things like the maximum buffer size (reduced it from 400 MB to 100 MB, might be a default of 10% percentage of the total memory), as I found when transcoding it will try to transcode as much as possible, you will notice the CPU usage of mencoder.exe while it fills the buffer at first and when the buffer starts to get empty – reducing the overall size allows to brake down the workload in smaller and regular chunks; it’s your choice really if you leave it with the default buffer.

The number of cores is defaulted in there, I didn’t change it (in my case two cores), you get to use both of them in the next screen.

Video quality section is a drop down and you get to choose the best setting for your system – obviously better quality comes with more processing power required and larger amounts of data to be transferred to the client, play with those to find your best settings.


Move to the next entry on the left, MEncoder and make some more configurations, mainly to uncheck the “Switch to txMuxer when H264 video is PS3 compatible” – since I’m streaming a H264 video this setting is appropriate for PS3 as it streams the video as it is obviously for better quality, but in our case here the video data / resolution is too much for Xbox so we’ll need to uncheck it.

I left the “Enhanced multicore support for H264 HD content…” unchecked although I do have two cores I noticed that one handles the transcoding just fine and didn’t want to overwork the laptop. Feel free to use if you want, seems to work just fine.


Now configuration completed you can restart PS3 Media Server (I’ve no idea whether pushing the Restart HTTP server button at the top is enough, personally I’ve restarted the software by closing it using the green play button in the icon tray area and restart it. I actually had to do that a few times and even logoff / restart XBMC4Xbox a few times to get the two seeing each other while making the configuration trial changes.


Useful tips:


I will mention here a few things that might come in handy. If you find that MEncoder.exe will crash while transcoding the video, you might notice that you can still navigate the uPnP shares from XBMC as they might be cached, but you might need to restart PS3 Media Server to get it accessible again. Since it’s a java application I’ve noticed that sometimes when quitting the app it still leaves the java.exe (1 or even 2 at times) behind. You should either wait for those to clear or kill them before starting the application again. If you don’t do that you will not be able to see the PS3 Media Server in XBMC although from your point everything seem to be up and running.

Use Process Explorer to look for the the java.exe process or kill it (make sure you check the startup directory so you don’t kill some other java apps you might have running on your PC), see screenshot below. Once cleared start PS3 Media Server again.



XBMC configuration


PS3 Media Server is a uPnP server so you will need to add a uPnP source. Go to Videos > Files and use the context menu to Add a source.





Now with the new source configured you can navigate it just like any other local or SMB source. You will notice though that besides the video files you will have additional folder entries where you can change settings on the server side (didn’t do much of those) or choose to play the original video or the transcoded version.




Notice that since I’ve added the MP4 extension to the TranscodedExtensions list in XBMC.conf it won’t display the original MP4 video (which although would play on XBMC will play very slowly), but the transcoded version of it. Otherwise you would have to enter the #—TRANSCODE--# folder and play from there.

Before moving to the play screenshots I will mention that when you start navigating the PS3 Media Server contents it will show the XBMC client is connected:


and when playing the transcoded contents the buffer starts to fill and the CPU usage will go up when mencoder.exe starts doing the business. As I mentioned earlier the CPU usage will go down when the buffer gets filled and then it will go up again at times to keep the buffer full.


Here are some XBMC screenshots while playing the transcoded stream – some shots are in 640x360 and some in 720x576 as I was playing with things, notice the video info in the top area as well as the CPU and memory usage (debug mode).





VLC streaming & transcoding to XBMC for Xbox

Some people have asked for a quick guide on how to stream / transcode from VLC (Windows) to XBMC for Xbox so here it is – this is not meant to be the guide, but more of a playground test from where anyone can take off.

This is what I’ve used:
  • XBMC4Xbox 3.0 beta2 r30758 running in 720p;
  • VLC Windows v1.1.5;
  • Home (2009) documentary – video H264 MPEG4-AVC, 1280x720, 24fps (avc1); audio MPEG AAC (mp4a), stereo, 44.1 KHz (as reported by VLC);
  • Dell Vostro 1520 running Windows 7 Professional x64.

VLC setup / configuration


VLC > Media > Streaming… > File (tab>)



I went for HTTP streaming cause it’s easier – select HTTP and click the Add button. That will allow you to configure the port and the URL – those will go into a .strm file that you will be playing in XBMC.


In my case the contents will be accessible from http://vostro:8080/stream (as you’ve guessed already Vostro is the name of my laptop); the port 8080 is offered by default and you can use it provided that you don’t have another application using it, in which case you will have to change it; the stream part is my choice.


In the lower section tick Activate Transcoding and you can choose one of the predefined profiles and customize it, or you can create a new one using the “Create new profile” button (3rd button). I chose to create my own profile and went to use WMV. Some profiles will require additional codecs that will be used for encoding the new stream, but I didn’t go into playing with those too much, I’ll leave that to you; I went for WMV cause it was the easy choice.


“Keep original video track” is unchecked cause otherwise it will stream the original contents. You can configure the bitrate and the frames per second – think of bitrate as the amount of data used to draw the picture, the more data the better the picture, but in the same time the more to transfer over the network (think of wireless here) and more data to decode on the client (more CPU required), so don’t go too high or too low, play with it to find a compromise between picture quality, network and CPU performance. It is in kb/sec which is common in communications but most people think in KB/sec so divide that by 8 to get some real sense of the amount of data.

The scale / sizing part controls the size of the output – in my case, the input is a 1280x720 video so scaling the output at 0.6 will result in a 768x432 video stream.


On the audio tab I went for WMA although you can probably also keep the original audio stream untouched (not transcoded), your choice.


I didn't play with subtitles, so go ahead and save the profile. Now back to streaming dialogs, tick the box to Activate Transcoding and select your new profile (or whatever profile you chose to go with) and click Next.


The final screen shows you the options you just configured earlier, where you can customize them or even paste them if you already have them prepared – it’s the same options you can find in the VLC wiki pages.


That’s it, press Stream to start streaming / transcoding. You will be controlling the stream from your PC, pausing, navigating, sound level etc.



XBMC side

You will now create a .strm file to point to the machine that we just configured and ran VLC – in my case this is http://vostro:8080/stream, where vostro is the name of the PC and the port and the stream part configured earlier. Transfer the .strm file to your Xbox and play it.


As mentioned earlier you won’t be able to navigate the stream from your XBMC because the video is one continuous stream that’s served from your PC; navigation is done on the VLC “server” side.

Here are some screenshots from the XBMC playing the stream, one with the settings above and one with a slightly larger size with the debug enabled to see how it handles it (notice the top side details).




Tuesday, December 7, 2010

How to find your Windows installation date

To find my Windows installation date I usually looked at C:\WINDOWS creation date, but right now that seems a bit older than I remember...

A more reliable way is to ask Windows about it and that is through System Info tool, filtering for "install date".

Start a command line (cmd.exe) and type:

systeminfo | find /i "install date"

Sunday, November 28, 2010

SplitButton .Net control

http://wyday.com/splitbutton/

SplitButton is a free, open source, button control that allows you to add menus to your buttons similar to Office 2003 and Office 2007 buttons. This type of control is frequently called by other names such as "menu button," "split button," and "drop down button." SplitButton is written in c# and works with all .NET languages (VB.NET, C#, etc.).

Features at a glance

SplitButton Screenshot
SplitButton works with either ContextMenu or ContextMenuStrip controls. SplitButton also correctly renders with the visual style of the operating system.

How to use SplitButton control in your application
http://wyday.com/forum/viewtopic.php?f=2&t=24

Wednesday, October 6, 2010

ProUnit – unit testing framework for PROGRESS 4GL

http://prounit.sourceforge.net/

What's ProUnit ?

ProUnit is a framework to create automated unit tests for Progress 4GL platform. It's based on other XUnit frameworks, like JUnit, NUnit and others.

Why should I use ProUnit ?

Today's software complexity makes it really hard to avoid bugs during all development process and sometimes it's just impossible (or too expensive) to manually test the software.

Most of the popular methodologies today (specially the agile ones) suggest that you should follow some best practices, including component-driven architecture and continuous tests. ProUnit is a key tool for this scenario because it encourages the creation of components during development process, and enables testing them continuously so any bug may be fastly detected.

Check ProUnit User Guide to see details of how using ProUnit on you projects.

How can I get it ?

ProUnit is an open source project on SourceForge. You can download the source code, build it (using your version of Progress), do some changes (if needed) and contribute to the project.

Get Involved

You can contribute to the project, participating on the forums, submitting bugs or new feature requests or helping on the new developments.

Font Survey: 42 of the Best Monospaced Programming Fonts – CodeProject

By Hans Dietrich | 18 Aug 2010
http://www.codeproject.com/KB/work/FontSurvey.aspx

This article presents commonly used programming fonts with examples of each font in ClearType and non-ClearType.

Introduction

Recently I have seen several blogs talking about which fonts are best for use in programming. Some blogs list two or three fonts, some list ten fonts. But I knew there were more fonts than the ones I was reading about, so I decided to look around to see how many I could find.

Here are some of the things I look for in a programming font:

  • Easy to read - clear letters, with easily distinguishable punctuation
  • Monospaced - this really follows from the point above. Although I know some programmers who insist that Arial or Verdana can be used in an IDE or programming editor, I have only included fixed-width fonts in this survey.
  • Adequate whitespace - fonts that are too compressed are more difficult to read, and make it more difficult to catch errors
  • Differentiated similar letters (1 and l, zero and O) are easy to tell apart

The Fonts

The following table lists in alphabetical order the most commonly cited programming fonts. While many are free, there are some that are only available via purchase, for $US8 - $US150. For reference, you might want to look at the CodeProject list of best programming fonts.

I look at fonts no differently than I look at other programming tools - they are professional investments. I discourage illegal use or copying of fonts. If you find a font that you cannot live without, then you should buy it if it is sold commercially. The price of fonts amounts to only pennies per hour, when you add up all the time you will spend looking at it.

    Continue reading… [http://www.codeproject.com/KB/work/FontSurvey.aspx]

    Saturday, September 11, 2010

    Microsoft Fix it Solution Center

    msfixit
    http://support.microsoft.com/fixit

    Thank you for your interest in Microsoft Fix it. We're working hard to automate solutions to common software problems in an easy, intuitive way that is available when and where you need it. So whether you are looking for a solution in help or support content, or an error report, Fix it provides a way to apply automated fixes, workarounds, or configuration changes so you don’t have to perform a long list of manual steps yourself.

    Saturday, July 31, 2010

    Power Dimmer screensaver

    http://www.whitsoftdev.com/powerdimmer/

    If you are like me where you have a main computer that you use most of the time but you also have a laptop on the side for reading emails or messaging, this is a nice screensaver that allows to dim the screen after a couple of minutes, but you can still see what’s going on. I noticed that at full brightness I was checking it far too often and my old laptop doesn’t support the built-in dimming feature in Windows 7.

    Although the project page says it requires Windows 2000 or XP, it works fine for me on Windows 7 x64 Enterprise edition.

    Saturday, July 10, 2010

    My case of Windows 7 0x0000007b BSOD

    We’ve started rolling Windows 7 x64 Enterprise at work with new laptops and thanks to a colleague in IT I was enrolled as well for my work Dell Latitude D630 laptop running Windows XP Professional, but I was going to do it myself at home over the weekend.

    After backing up my files on an external USB drive and restoring the Norton Ghost image (I did manage to restore just the system partition so I could’ve kept the others untouched, but it wasn’t worth risking), then I had to go through the recovery process and let Windows 7 repair the boot so that replaces the Windows XP boot manager. That is a nice tool and it works in most cases, what it doesn’t do is help with ATA vs AHCI modes.

    And this is where the troubles begun – I understand that the image was preset for ATA mode, while previously my XP was configured for AHCI mode, and therefore I was hit hard with 0x0000007B (0xFFFFF88009A9928, 0xFFFFFFFFC0000034, 0x000000 …)  BSOD.

    I figured that it must be  because of that so I went in BIOS and changed from AHCI to ATA. Trouble was that it didn’t solve the problem… Went again through the Windows 7 recovery mode, nothing.

    Googling the problem I found that most of the solutions were suggesting to change the SATA mode in BIOS, but that didn’t solve it for me (I changed to both, reset the BIOS setting etc no luck)– some explained that Windows loads either the AHCI or ATA drive as configured. Then I found this Microsoft KB (http://support.microsoft.com/kb/922976) that says how to change the registry keys to enable AHCI mode.

    BUT how to change the registry keys when my Windows wasn’t booting up?! What I didn’t know is that you can run regedit.exe from the recovery console and then load the SYSTEM hive from HDD, change the registry keys and then unload it!!!

    Searching for “how to edit registry files from recovery console” I found this article - http://windowsxp.mvps.org/peboot.htm - which was written for something else but I could use it to load the SYSTEM hive from C:\Windows\System32\Config\SYSTEM, went in both ControlSet001 and ControlSet002 (to be sure :-) and changed the two Msahci\Start and IastorV\Start to 0 (from 3), rebooted with AHCI mode in BIOS and BINGO, my new Windows 7 was booting fine now!

    Case closed - thanks to other people sharing the information, I thought I should do the same and pay it forward…

    PS: If your system supports and has AHCI enabled you can install Intel Rapid Storage for an updated driver from here (search for Intel Rapid Storage – it is not detected automatically). Intel Rapid Storage Manager used to be called Intel Matrix Storage Manager.

    Sunday, July 4, 2010

    PHP HTTP compression (gzip)

    Hosting your PHP web application on server that doesn’t have compression enabled at the web server level? No worries, enable compression in your application by placing this code at the top of your page:

      <?php
    ob_start("ob_gzhandler");
    ?>

    http://php.net/manual/en/function.ob-gzhandler.php

    ob_gzhandler() is intended to be used as a callback function for ob_start() to help facilitate sending gz-encoded data to web browsers that support compressed web pages. Before ob_gzhandler() actually sends compressed data, it determines what type of content encoding the browser will accept ("gzip", "deflate" or none at all) and will return its output accordingly. All browsers are supported since it's up to the browser to send the correct header saying that it accepts compressed web pages. If a browser doesn't support compressed pages this function returns FALSE.

    * * *

    Related posts:
    http://dandar3.blogspot.com/2010/04/http-compression.html

    Thursday, June 24, 2010

    7-Zip Theme Manager

    http://7ztm.de.vu/

    Many users of the excellent file archiver 7-Zip criticized its nostalgic appearance. That's exactly where my program "7-Zip Theme Manager", in short "7zTM", comes in and offers the following features:

    Stylish...
    • Toolbar Themes - change the look of the toolbar of 7-Zip
    • Filetype Themes - change the look of archived files, for instance in Explorer
    • *new* 90 Toolbar Themes and 22 Filetype Themes integrated
    • *new* changing the SFX-icon (self-extracting archive) is now possible - see FAQ #5
    Handy...
    • automatic or manual search of the 7-Zip installation folder
    • convenient activation of the Themes with just a click
    • Themes previews integrated directly into the program
    • multi-lingual user interface
    • online update for up to date Themes and features - see FAQ #6
    • possibility to create your own Themes
    • *new* supports 7-Zip 32-Bit and 64-Bit

    Costs?

    0, Nichts, Nada, Niente, Nothing, Rien, Tipota, 12-3x4

    Bild "German:7ztm_preview_2.jpg"

    Bild "German:7ztm_preview_1.jpg"

    Sunday, June 13, 2010

    ImageShack.us image upload (C# code)

    Spent a couple hours yesterday looking for some code to upload images to ImageShack.us (I need it for a XBMC for Xbox remote control app I’m writting) and thought I might share the code.

    The image I have is already available in a PictureBox and this only concentrates on the upload itself, won’t go into parsing the XML reply, that should be fairly easy to implement it yourself…

    More information about the ImageShack.us Upload API and how to apply for a key here:
    http://code.google.com/p/imageshackapi/wiki/ImageshackAPI

    Working example here:
    https://code.google.com/p/dandar3-apps/source/browse/#svn/trunk/ImageShack Upload

    /**
     * ImageShack Unified upload API
     * http://code.google.com/p/imageshackapi/wiki/ImageshackAPI
     */
    private void buttonUpload_Click(object sender, EventArgs e)
    {
      //
      Cursor.Current = Cursors.WaitCursor;
    
      //
      // Init
      //
      String      filename    = "fake_name";
      String      mimeType    = "image/jpeg";
      ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
    
      //
      // Prepare POST contents...
      //
      MemoryStream memoryStream = new MemoryStream();
    
      // Parts boundary
      String boundary = "-------" + DateTime.Now.Ticks.ToString("x");
      String crlf     = "\r\n";
      
      // Image file...
      write(memoryStream, "--" + boundary + crlf);
      write(memoryStream, String.Format("Content-Disposition: form-data; name=\"fileupload\"; filename=\"{0}\"", filename) + crlf);
      write(memoryStream, String.Format("Content-Type: {0}", mimeType) + crlf);
      write(memoryStream, crlf);
      
      pictureBox.Image.Save(memoryStream, imageFormat);
      write(memoryStream, crlf);
      
      // Other parameters (Key, Username, Password etc)
      NameValueCollection parameters = new NameValueCollection();
      parameters.Add("key",        "your_key");
      parameters.Add("a_username", "your_username");
      parameters.Add("a_password", "your_password");
      parameters.Add("tags",       "your_tags");
    
      foreach (String param_name in parameters.Keys)
      {
        write(memoryStream, "--" + boundary + crlf);
        write(memoryStream, String.Format("Content-Disposition: form-data; name=\"{0}\"", param_name) + crlf);
        write(memoryStream, crlf);
        write(memoryStream, parameters.Get(param_name));
        write(memoryStream, crlf);
      }
    
      // End...
      write(memoryStream, "--" + boundary + crlf);
      
      //
      // Upload (POST)...
      //
      try
      {
        HttpWebRequest webRequest = (HttpWebRequest) HttpWebRequest.Create("http://www.imageshack.us/upload_api.php");
        webRequest.ContentType    = "multipart/form-data; boundary=" + boundary;
        webRequest.Method         = "POST";
    
        //
        // Request
        //
        webRequest.ContentLength = memoryStream.Length;
        using (Stream requestStream = webRequest.GetRequestStream())
        {
          memoryStream.Seek(0, SeekOrigin.Begin);
          memoryStream.WriteTo(requestStream);
        }
    
        //
        // Response
        //
        using (WebResponse  webResponse  = webRequest.GetResponse())
        using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
        {
          String imageshackReply = streamReader.ReadToEnd().Trim();
          MessageBox.Show(imageshackReply, "HTTP POST Response", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.Message, "HTTP POST Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
    
      //
      // Clean-up...
      //
      memoryStream.Close();
    }
    
    /**
     * 
     */
    private void write(MemoryStream p_memoryStream, String p_data)
    {
      byte[] bytes = Encoding.ASCII.GetBytes(p_data);
      p_memoryStream.Write(bytes, 0, bytes.Length);
    }
    

    Saturday, June 12, 2010

    Network Monitor v0.8

    Network Monitor, 0.8 - 12 June 2010

    [download: binaries | sources]

    • remeber last used network device;
    • rewrite 4 GB "wrapping" logic;
    • embed readme.txt (display in About box);

    imageimage

    Monday, May 10, 2010

    Remote Desktop Connection 7.0 client for Windows XP & Vista

    remotedesktop

    RDP 7.0 protocol included with Windows 7 and 2008 R2 brings some nice enhancements (WMP redirection, bidirectional audio, multi-monitor support, Aero glass transparency etc), and now those features are available through the new Remote Desktop Client for Windows XP and Vista. See more below:

    * Description of the Remote Desktop Connection 7.0 client update for Remote Desktop Services (RDS) for Windows XP SP3, Windows Vista SP1, and Windows Vista SP2
    http://support.microsoft.com/kb/969084

    * Remote Desktop Connection 7 for Windows 7, Windows XP & Windows Vista
    http://blogs.msdn.com/rds/archive/2009/08/21/remote-desktop-connection-7-for-windows-7-windows-xp-windows-vista.aspx

    image

    Microsoft Visual Studio 2010 Express

    image  
    http://www.microsoft.com/express/

    Monday, April 12, 2010

    We are pleased to announce that the Visual Studio 2010 Express release is now available for download on the Visual Studio Express Web Site!

    The Visual Studio Express Editions are simplified versions of the Visual Studio Professional product, tailored for beginner and hobbyist developers. They offer power and productivity in a simple package and best of all, they are free!

    New for this release, we have created a streamlined user experience that focuses on the most common commands by hiding some of the more advanced menus and toolbars.  All of the Express features are still available via the Tools > Settings > Expert Settings menu.

    Learn more about the Visual Studio Express products:

    · Using Visual Studio Express to create Windows Applications
    · Using Visual Studio Express to create Web Applications

    Adrian Collier
    Program Manager - Visual Studio Express

    Saturday, March 27, 2010

    XBMC for Xbox – how to disconnect an FTP connection

    You might have the case where you are transferring files to your Xbox Media Center and it gets disconnected (usually through wi-fi) and when your FTP client will try to re-connect it will be denied, as there are only two simultaneous connections allowed, you will have to wait for a minute (the default timeout) or reboot the Xbox.

    If you don’t want to wait or if your Xbox is in the other room, here is how you can close those hung connections from your Windows PC.

    To allow remote admin connections, connect through FTP, download Q:\System\FileZilla Server.xml and edit on your PC to change the Admin IP Addresses to match your network IP address class (in my case, 10.0.0.* - default is 192.168.0.*), then upload back.


    Install an older version of the FileZilla Server like. 0.8.9 from here - that is because the protocol has changed in later versions. You can uninstall the application and only keep the FileZilla Server Interface.exe if you want.

    Run the FileZilla Server Interface and connect to your Xbox (default password is xbmpzilla, it can also be changed in the above XML configuration file).


    On the right side you will see the active connections, right click one of them and use “Kick” to disconnect. Simples!


    An added benefit from using the FileZilla Server Interface is that now you can change server settings without having to download and edit the XML configuration file every time ;-) not that you should need to, but but might be useful.

    Single Instance Application in C# (per session)

    Sometimes you want to only allow for a single instance of your application and that can be accomplished by using a Mutex class. On top of that, if it’s used on a Terminal Server / Citrix, you also want to check the session id, to ensure you’re not interfering with other user’s instances or even the same user on a different connection.

    EDIT: On a second read, the SID might not be needed in the mutex name, as by default the mutex is local, unless told otherwise, see note below:

    http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx

    * * *

    [DllImport("user32.dll")] 
    [return: MarshalAs(UnmanagedType.Bool)] 
    static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); 
     
    [DllImport("user32.dll")] 
    [return: MarshalAs(UnmanagedType.Bool)] 
    static extern bool SetForegroundWindow(IntPtr hWnd);
     
    // Constants 
    const int SW_RESTORE = 9;
     
    /// <summary> 
    /// The main entry point for the application. 
    /// </summary> 
    [STAThread] 
    static void Main() 
    { 
      // 
      // Use a Mutex to allow only one instance per session...  
      // 
      bool   newInstance = true; 
      String mutexId     = String.Format("APP={0}; SID={1}",
                                         Assembly.GetExecutingAssembly().GetName().Name, 
                                         System.Diagnostics.Process.GetCurrentProcess().SessionId); 
     
      Mutex mutex = new System.Threading.Mutex(true, mutexId, out newInstance);  
      if (!newInstance) {
        MessageBox.Show("Application Already Running!" + mutexId);
     
        // Find the instance holding the mutex and restore...  
        Process currentProcess = Process.GetCurrentProcess();  
        foreach (Process process in Process.GetProcessesByName(currentProcess.ProcessName))  
        {  
          if (process.Id        != currentProcess.Id &&  
              process.SessionId == currentProcess.SessionId)  
          { 
            // Restore window (if minimized)... 
            ShowWindow(process.MainWindowHandle, SW_RESTORE); 
     
            // Set foreground window... 
            SetForegroundWindow(process.MainWindowHandle);
     
            break;  
          }  
        }  
        return;  
      }
     
      //  
      // Run normal...  
      //  
      Application.EnableVisualStyles();  
      Application.SetCompatibleTextRenderingDefault(false);  
      Application.Run(new MainForm()); 
     
      //
      // Hold the mutex from being garbage collected... 
      //
      GC.KeepAlive(mutex);
    }

    Resources:

    Saturday, March 20, 2010

    XBMC Python tips – how to get build version & date

    Python code:

    import xbmc
    result = xbmc.executehttpapi('GetSystemInfo(120;121)')
    system_info    = result.split('<li>')
    print "Version = " + system_info[1]
    print "Date    = " + system_info[2]

    or

    import xbmc
    result = xbmc.executehttpapi('GetSystemInfoByName(system.buildversion;system.builddate)')
    system_info    = result.split('<li>')
    print "Version = " + system_info[1]
    print "Date    = " + system_info[2]

    or even a simpler alternative, suggested by BigBellyBilly:

    import xbmc
    version = xbmc.getInfoLabel('System.BuildVersion')
    date    = xbmc.getInfoLabel('System.BuildDate')
    print "Version = " + version
    print "Date    = " + date

    Result :

    Version = 9.11 r26017 
    Date    = Dec 23 2009

    References:

    Wednesday, March 3, 2010

    Windows 7 system waking up at night

    A common reason for a computer to wake up is that a network interface was configured to Wake on LAN (WoL) (usually company computers) – that means it can wake up due to a link change signal or a Magic Packet. This feature can be quite useful if you want to wake up your work computer, first logon through the company VPN and then run a WoL software from one of the Citrix / Terminal Server sessions (usually WoL packets are not allowed through gateways from the Internet). Nowadays even wireless network devices allow for WoL (depending on BIOS and motherboard).

    To disable (or enable) WoL, see this article below for more details – simply check/uncheck the the box that says “Allow this device to wake the computer” accordingly. The “Only allow management stations to wake the computer”  I believe it means to wake up only on Magic Packet requests.

    http://www.howtogeek.com/howto/windows-vista/fix-sleep-mode-randomly-waking-up-issue-in-windows-vista/
    image

    Another reason for your Windows system waking up, and probably more common to Windows 7 editions including Media Center (e.g. Professional), is that if the computer supports APM 1.2 or later it is possible to have tasks that can wake up the system from S4 (Hibernation) or S5 (Power Off) – most common seems to be the case with the Media Center Update scheduler task – see more details below.

    http://www.beirtech.com/blogs.php?action=view&bid=6

    Notice the “Wake the computer to run this task” is checked - either uncheck the box (double click the task scheduler entry to edit) or simply disable the task altogether.


    Saturday, February 13, 2010

    Dell Vostro 1520 – driver updates

    Windows Experience Index before updating the drivers.

    image

    Personal note, I usually keep all drivers in D:\_Drivers, in folders per component containing the driver archive (including the version in the name of the file or in a separate readme) and a link to the provider’s website - it makes it easier to check later for driver updates.

    To Dell’s credit the system came with quite recent drivers, most users don’t need to do this, unless of course you are the type that likes to experiment with newer drivers.

    • Intel Driver Update Utility (auto-detection)

    This is a really good resource, at least for your Intel components, no need to go and pick them (requires an ActiveX install, use the Internet Explorer 32bit):

    http://www.intel.com/support/detect.htm?iid=dc_iduu

    • Intel Chipset Identification

    http://www.intel.com/support/chipsets/id/

    Although I ran the utility as administrator, as the popup says, it didn’t allow me to run it. I’ve used CPU-Z which reports GM45/GM47 chipset.

    image

    A useful link from where to get the graphics, chipset and storage drivers is:

    http://www.intel.com/support/chipsets/sb/CS-029319.htm

    • Graphics driver

    Dell’s support site has a slightly older Intel graphics driver (04/11/2009, 8.15.10.1840) than the one on the Intel site (8.15.10.1986) – going for the Intel one.

     http://www.intel.com/support/graphics/detect.htm

    • Wireless driver (Intel Wi-Fi 5300)

    System driver : 12.4.1.11, Dell’s website : 13.0, A01, Intel’s website : 13.0.0.107 – going for Intel’s driver.

    http://www.intel.com/support/wireless/detect.htm

    • Intel Chipset Driver (Mobile Intel® 4 Series Express Chipset Family)

    http://downloadcenter.intel.com/SearchResult.aspx?lang=eng&ProductFamily=Chipsets&ProductLine=Chipset+Software&ProductProduct=Intel%c2%ae+Chipset+Software+Installation+Utility

    • Intel Matrix Storage

    The system came with the latest AHCI enabled drivers, but it didn’t include the Intel Matrix Storage Console, so I just installed the Intel package from:

    http://downloadcenter.intel.com/scripts-df-external/Product_Filter.aspx?ProductID=2101

    image
    * * *

    A very good idea is to start from http://support.dell.com website, where it can detect the tag of your system and will provide you with a page where you can select the operating system and get the appropriate drivers for your system.

    The you can find drivers or firmware updates for your HDD (mine already had the latest firmware available, as it can be seen in Intel Matrix Storage Console), audio drivers (also latest version, usually it’s quite hard to find these off the web, providers usually rely on OEM channels) or the more important BIOS updates (do not apply these unless in the release notes you see a fix for problem that you’ve been experiencing as well – updating BIOS incorrectly could brick your system and you will have to send it back for repairs).

    Already having recent drivers, I didn’t expect a huge leap forward in performance, there’s very small differences, probably not worth the effort if you’re already happy with the overall performance.

    image

    To keep the performance at top levels you should regularly clean your system (using Windows CleanUp tool or 3rd party tools like CCleaner) and defrag your hard drive (Windows Defrag or 3rd party tools like PerfectDisk).