<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Damir Arh's Corner</title>
  <link rel="alternate" type="text/html" href="http://www.damirscorner.com/" />
  <link rel="self" href="http://www.damirscorner.com/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2008-07-05T22:37:14.222375+02:00</updated>
  <author>
    <name>Damir Arh, M. Sc.</name>
  </author>
  <subtitle />
  <id>http://www.damirscorner.com/</id>
  <generator uri="http://www.dasblog.net" version="1.8.5223.2">DasBlog</generator>
  <entry>
    <title>Gama System eArchive accredited</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/GamaSystemEArchiveAccredited.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,4e0955bd-674c-4a1f-b657-91a361e2c0eb.aspx</id>
    <published>2008-07-05T22:37:14.222375+02:00</published>
    <updated>2008-07-05T22:37:14.222375+02:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/.NET" label="Development/.NET" scheme="dasBlog" />
    <category term="Personal" label="Personal" scheme="dasBlog" />
    <category term="Personal/Software" label="Personal/Software" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://gama-system.com/Content.aspx?id=20050200">Gama System eArchive</a>,
      one of the two products in our <a href="http://gama-system.com/Content.aspx?id=20050050">document
      product line</a>, received accreditation from the <a href="http://www.arhiv.gov.si/en/">Archives
      of the Republic of Slovenia</a> last week. This acknowledgement by our national body
      means that any document stored in Gama System eArchive is automatically legally valid.
   </p>
        <p>
      This is important for both <a href="http://gama-system.com/NewsItems.aspx">our company</a> and
      other companies looking for a long term electronic document storage solution. Our
      product is the first service oriented solution to receive the accreditation.
   </p>
        <p>
      Congratulations to everyone involved in the product. Well done!
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=4e0955bd-674c-4a1f-b657-91a361e2c0eb" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Microsoft Pro Photo Tools decimal separator problem</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/MicrosoftProPhotoToolsDecimalSeparatorProblem.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,de988151-8abf-4eef-bdc2-1126b05812b1.aspx</id>
    <published>2008-06-15T22:03:01.887375+02:00</published>
    <updated>2008-06-15T22:03:01.887375+02:00</updated>
    <category term="Personal" label="Personal" scheme="dasBlog" />
    <category term="Personal/Software" label="Personal/Software" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Today I've taken my new <a href="http://buy.garmin.com/shop/shop.do?pID=8703">handeld
      GPS device</a> for a test run. It did its job pretty well but the real challenge started
      afterwards when I tried geotagging the photos I've taken. I decided to use <a href="http://www.microsoft.com/prophoto/downloads/tools.aspx">Microsoft
      Pro Photo Tools</a> which have just been released with geotagging as its main feature.
      Downloading the track data from the GPS device with Garmin MapSource software was
      quick and simple. But the problems started soon afterwards. MapSource can only export
      track data in its proprietary format GDB which can't be used in Microsoft Pro Photo
      Tools.
   </p>
        <p>
          <a href="http://www.gpsbabel.org/">GPSBabel</a> came to the rescue. This free tool
      can probably convert files between any two existing GPS formats, at least judging
      from its <a href="http://www.gpsbabel.org/capabilities.html">list of supported formats</a>.
      I used it to convert my data to the GPX XML format only to find out that Microsoft
      Pro Photo Tools have problems with it. Converting to NMEA or KML instead didn't help
      either. Fortunately the latter returned a strange error (Degrees must be between 0
      and 90, found degree 46298501) which put me on the right track. Of course there was
      no such value in the KML file so I correctly deduced that the decimal separator was
      to blame.
   </p>
        <p>
      The value in the file was 46.298501 but the Slovenian regional settings have comma
      as the decimal separator therefore the value was misinterpreted. Temporarily changing
      the decimal separator to dot solved the problem - the track was successfully imported
      immediately afterwards. This issue won't keep me from using this otherwise very useful
      tool with a really nice feature set. It could even fix the mismatching time settings
      between my GPS unit and the camera with a single setting. I just hope they address
      this bug soon so that I won't have to change my regional settings every time I use
      the program.
   </p>
        <p>
      The only thing I still have to figure out is why the geotags somehow lost resolution
      when I uploaded the photos from <a href="http://picasa.google.com/">Picasa</a> to <a href="http://picasaweb.google.com/">Picasa
      Web Albums</a>. I just fixed them manually and decided to address the issue next time.
      Any tips are welcome.
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=de988151-8abf-4eef-bdc2-1126b05812b1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Old ActiveX controls under .NET 2.0 SP1</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/OldActiveXControlsUnderNET20SP1.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,84c751f7-f67e-47f0-9def-3035b5333cf5.aspx</id>
    <published>2008-04-29T15:29:08.442625+02:00</published>
    <updated>2008-04-29T15:29:08.442625+02:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/.NET" label="Development/.NET" scheme="dasBlog" />
    <category term="Development/Vista" label="Development/Vista" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      A .NET application in the company I work for recently started crashing under Windows
      Vista when trying to open a window implemented in an ActiveX DLL. Investigations showed
      that they were caused by an <font face="Courier New">AccessViolationException "Attempted
      to read or write protected memory. This is often an indication that other memory is
      corrupt."</font>. The cause was one of the ActiveX controls in the window. When instantited
      directly in a .NET Form the exception above was contained in a <font face="Courier New">TargetInvocationException
      "Unable to get the window handle for the '&lt;control name&gt;' control. Windowless
      ActiveX controls are not supported."</font>. Knowing that the control didn't suddenly
      turn windowless we dug deeper.
   </p>
        <p>
      It turned out that the problem appeared with .NET Framework 2.0 Service Pack 1. <a href="http://blogs.msdn.com/ed_maurer/archive/2007/12/14/nxcompat-and-the-c-compiler.aspx">Apparently</a> it
      caused the C# compiler in Visual Studio 2005 and later to set the <font face="Courier New">NXCOMPAT</font> bit
      for all build targets without an option to turn this new behavior off. For those who
      don't know, this means that DEP (data execution prevention) will kick in unless it
      is turned off completely in the operating system. This wouldn't be a big deal unless
      ATL before Visual Studio 2005 didn't have a <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=299397">bug</a> which
      caused the heap allocated memory not to be flagged as executable, which under the
      new circumstances results as the already mentioned exception. Windows XP has DEP turned
      off by default therefore everything still works but in Windows Vista it is turned
      on and prevents such application from functioning properly.
   </p>
        <p>
      The best solution would of course be to recompile the ActiveX controls in Visual Studio
      2005 or later but this might not be possible if they are supplied by a third party.
      In this case the most obvious approach to dealing with the situation is to disable
      DEP in Vista. There is a <font face="Courier New">Data Execution Prevention</font> tab
      in the <font face="Courier New">Performance Options</font> which open when you click
      the <font face="Courier New">Settings</font> button in the <font face="Courier New">Performance</font> frame
      of the <font face="Courier New">Advanced</font> tab in the <font face="Courier New">System
      Properties</font> dialog but it only allows switching between DEP for all processes
      with defined exceptions and DEP for essential Windows programs and services, i.e.
      executables flagged with the <font face="Courier New">NXCOMPAT</font> bit. The only
      way to turn DEP completely off is executing the following command with administrative
      privileges:
   </p>
        <p>
          <font face="Courier New">bcdedit.exe /set {current} nx AlwaysOff</font>
        </p>
        <p>
      After restart DEP will be turned off and problematic binaries will work once again.
      To restore the previous (default) state replace <font face="Courier New">AlwaysOff</font> with <font face="Courier New">OptIn</font>.
      The <font face="Courier New">AlwaysOn</font> option enables DEP for all processes
      and might cause additional problems (e.g. Google Calendar Sync in its current version
      0.9.3.2 doesn't work in this mode).
   </p>
        <p>
      Unfortunately, this solution would require all your Vista using customers to disable
      DEP as well which really isn't an option for commercial software. Fortunately, there
      is another solution. Although there is no compiler option to turn keep the <font face="Courier New">NXCOMPAT</font> bit
      unset, you can still do this after compilation using the <font face="Courier New">editbin.exe</font> which
      comes with C++ compiler for Visual Studio 2005 and later:
   </p>
        <p>
          <font face="Courier New">editbin.exe /NXCOMPAT:NO &lt;filename.exe&gt;</font>
        </p>
        <p>
      This command removes the <font face="Courier New">NXCOMPAT</font> bit and restores
      the behavior before .NET 2.0 SP1. If your assembly was signed it also invalidates
      the signature so you'll have to resign it:
   </p>
        <p>
          <font face="Courier New">sn.exe -R &lt;filename.exe&gt; &lt;keyfile.snk&gt;</font>
        </p>
        <p>
      You can automate this by putting the two commands in the <font face="Courier New">Post-build
      event command line</font> for the project:
   </p>
        <p>
          <font face="Courier New">editbin.exe /NXCOMPAT:NO "$(TargetPath)"<br />
      sn.exe -R "$(TargetPath)" "$(ProjectDir)&lt;keyfile.snk&gt;"</font>
        </p>
        <p>
      You might need to call <font face="Courier New">vcvars32.bat</font> before that to
      put the required executables in path and enable <font face="Courier New">editbin.exe</font> dependencies
      to be resolved. Note that in a completely automated build scenario using <font face="Courier New">MSBuild</font> you'll
      have to specify full path for the <font face="Courier New">vcvars32.bat</font> because <font face="Courier New">$(DevEnvDir)</font> resolves
      to <font face="Courier New">*Undefined*</font> outside Visual Studio 2005. Also your
      strong name key should be in a <font face="Courier New">snk</font> file instead of
      a password protected <font face="Courier New">pfx</font> file because <font face="Courier New">sn.exe</font><a href="http://blogs.msdn.com/shawnfa/archive/2006/02/14/531921.aspx">doesn't
      allow</a> the password to be read from a redirected standard input.
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=84c751f7-f67e-47f0-9def-3035b5333cf5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>MonthCalendar BoldedDates in Windows Vista</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/MonthCalendarBoldedDatesInWindowsVista.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,ec1b3869-796e-4d12-8d41-614bcb51aad5.aspx</id>
    <published>2008-04-14T21:54:58.67825+02:00</published>
    <updated>2008-04-14T21:54:58.67825+02:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/.NET" label="Development/.NET" scheme="dasBlog" />
    <category term="Development/Vista" label="Development/Vista" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The <font face="Courier New">MonthCalendar</font> control's <font face="Courier New">BoldedDates</font> functionality
      doesn't appear to work properly on Windows Vista. The dates added to any of the <font face="Courier New">BoldedDates</font>, <font face="Courier New">MonthlyBoldedDates</font> and <font face="Courier New">AnnuallyBoldedDates</font> collections
      are rendered just the same as those not added to any of the collections. The same
      code works just fine on Windows XP and causes those dates to be rendered bold. The
      only workaround i've managed to <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2296827&amp;SiteID=1">find</a> is
      disabling visual styles in the application, i.e. commenting out the first line in
      the <font face="Courier New">Program.Main()</font> method of a new Windows Application:
   </p>
        <p>
          <font face="Courier New">Application.EnableVisualStyles();</font>
        </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=ec1b3869-796e-4d12-8d41-614bcb51aad5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Playing DivX and XviD videos natively on Xbox 360</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/PlayingDivXAndXviDVideosNativelyOnXbox360.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,fcd08df4-c6f8-4a1f-ae1f-c5ed70431510.aspx</id>
    <published>2007-12-31T12:34:14.984+01:00</published>
    <updated>2008-04-14T21:53:46.80325+02:00</updated>
    <category term="Personal" label="Personal" scheme="dasBlog" />
    <category term="Personal/Software" label="Personal/Software" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The Xbox 360 Dashboard update released on 4th December 2007 added support for playing
      DivX and XviD videos natively, i.e. without installing <a href="http://www.runtime360.com/projects/transcode-360/">Transcode
      360</a> for Windows Media Center. Unfortunatelly this only works for media played
      directly from the dashboard and not within Media Center Extender. Since I didn't want
      to copy my videos to CDs, DVDs or other external devices, the only thing left to do
      was to setup Windows Media Player media sharing which I never had to use before.
   </p>
        <p>
      This turned out to be more difficult than I expected - the reason being that the media
      I wanted to share wasn't stored locally but on a separate file server. By default
      such media is not shared and there are few steps one has to follow to make this work,
      as thoroughly explained <a href="http://www.microsoft.com/windows/windowsmedia/player/faq/sharing.mspx#q20_17">here</a>:
   </p>
        <ul>
          <li>
         Enable remote content sharing by adding the following entry into the registry:<br /><font face="Courier New">[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MediaPlayer\Preferences\HME]<br />
         "EnableRemoteContentSharing"=dword:00000001</font></li>
          <li>
         Grant anonymous users access to the shared folders on the file server by adding the
         read permission on the folder and on the share to the <font face="Courier New">ANONYMOUS
         LOGON</font> user 
      </li>
          <li>
         Modify the file server's group policy to allow anonymous access to the selected shares
         by listing them in the <font face="Courier New">Network access: Shares that can be
         accessed anonymously</font> policy in the <font face="Courier New">Computer Configuration,
         Windows Settings, Security Settings, Local Policies, Security Options</font> branch
         of the group policy tree (just run <font face="Courier New">gpedit.msc</font> to start
         the Group Policy Object Editor)</li>
        </ul>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=fcd08df4-c6f8-4a1f-ae1f-c5ed70431510" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Notes about RSACryptoServiceProvider</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/NotesAboutRSACryptoServiceProvider.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,eeb23ba8-38df-4a7b-8b2e-3fd5132e8a18.aspx</id>
    <published>2007-11-24T17:31:53.4825+01:00</published>
    <updated>2007-11-24T17:31:53.4825+01:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/.NET" label="Development/.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      In my opinion RSACryptoServiceProvider class is seriously under-documented in MSDN.
      Since there is also no abundance of examples on the web, I spent more time than I
      should figuring out how to use it correctly. For future reference I'm listing below
      the solution to two problems I had.
   </p>
        <p>
      The maximum byte array length for encrypting without OAEP padding is Modulus size
      - 11 which is written somewhere in the <a href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.encrypt.aspx">Encrypt()
      method documentation</a>. If you pass it a larger array it will return a not so informative
      Unspecified error. To encrypt a larger chunk of data you have to split it in smaller
      parts, encrypt them individually and concatenate them back together. You have to do
      the same when decrypting the data, with the only difference that each part has the
      size of Modulus in stead of Modulus - 11. To get the modulus size you can use the
      following piece of code (rsa is an instance of RSACryptoServiceProvider):
   </p>
        <div class="CodeFormatContainer">
          <pre class="csharpcode">RSAParameters rsaParams = rsa.ExportParameters(<span class="kwrd">false</span>); <span class="kwrd">int</span> modulusSize
      = rsaParams.Modulus.Length; </pre>
        </div>
        <p>
      Each time you instantiate RSACryptoServiceProvider it generates a new pair of keys.
      If you want to use existing ones, you can import them by calling:
   </p>
        <div class="CodeFormatContainer">
          <pre class="csharpcode">rsa.FromXmlString(key);</pre>
        </div>
        <p>
      The key parameter is a string with the XML representation of the keys. You can get
      it by calling the ToXmlString() method once and storing its results. It's only parameter
      specifies whether to also export the private key. I guess I don't have to remind you
      that you need the private key only for decryption and that you should always keep
      it private for the encryption to make any sense at all. 
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=eeb23ba8-38df-4a7b-8b2e-3fd5132e8a18" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Always close DeflateStream before reading results</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/AlwaysCloseDeflateStreamBeforeReadingResults.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,52003afd-e963-49d3-a950-388855fed432.aspx</id>
    <published>2007-11-24T16:44:37.123125+01:00</published>
    <updated>2007-11-24T16:44:37.123125+01:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/.NET" label="Development/.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Is the code below correct? Will inputString and outputString be equal?
   </p>
        <div class="CodeFormatContainer">
          <div class="CodeFormatContainer">
            <pre class="csharpcode">
              <span class="kwrd">string</span> inputString
         = <span class="str">"The text to compress and decompress"</span>; <span class="kwrd">byte</span>[]
         inputArray = Encoding.UTF8.GetBytes(inputString); MemoryStream stream = <span class="kwrd">new</span> MemoryStream();
         DeflateStream compressionStream = <span class="kwrd">new</span> DeflateStream(stream,
         CompressionMode.Compress); compressionStream.Write(inputArray, 0, inputArray.Length);
         compressionStream.Flush(); stream.Position = 0; DeflateStream decompressionStream
         = <span class="kwrd">new</span> DeflateStream(stream, CompressionMode.Decompress); <span class="kwrd">byte</span>[]
         outputArray = <span class="kwrd">new</span><span class="kwrd">byte</span>[inputArray.Length];
         decompressionStream.Read(outputArray, 0, outputArray.Length); <span class="kwrd">string</span> outputString
         = Encoding.UTF8.GetString(outputArray); Console.WriteLine(outputString == inputString);
         Console.ReadLine(); </pre>
          </div>
        </div>
        <p>
      As it turns out, they won't. The reason for it being that compressionStream.Close()
      was not called before reading from stream started. Calling compressionStream.Flush()
      is not enough in this case. I haven't managed to find this documented anywhere but
      the example in the <a href="http://msdn2.microsoft.com/en-us/library/system.io.compression.deflatestream.aspx">DeflateStream
      documentation</a> does it correctly. You can find the fixed code below. Notice the
      additional last parameter in the first call to the DeflateStream constructor. Without
      it stream will also be closed when compressionStream gets closed.
   </p>
        <div class="CodeFormatContainer">
          <div class="CodeFormatContainer">
            <pre class="csharpcode">
              <span class="kwrd">string</span> inputString
         = <span class="str">"The text to compress and decompress"</span>; <span class="kwrd">byte</span>[]
         inputArray = Encoding.UTF8.GetBytes(inputString); MemoryStream stream = <span class="kwrd">new</span> MemoryStream();
         DeflateStream compressionStream = <span class="kwrd">new</span> DeflateStream(stream,
         CompressionMode.Compress, <span class="kwrd">true</span>); compressionStream.Write(inputArray,
         0, inputArray.Length); compressionStream.Close(); stream.Position = 0; DeflateStream
         decompressionStream = <span class="kwrd">new</span> DeflateStream(stream, CompressionMode.Decompress); <span class="kwrd">byte</span>[]
         outputArray = <span class="kwrd">new</span><span class="kwrd">byte</span>[inputArray.Length];
         decompressionStream.Read(outputArray, 0, outputArray.Length); <span class="kwrd">string</span> outputString
         = Encoding.UTF8.GetString(outputArray); Console.WriteLine(outputString == inputString);
         Console.ReadLine(); </pre>
          </div>
        </div>
        <p>
      Thanks once again to my coworker for suggesting this when I was already running out
      of ideas.
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=52003afd-e963-49d3-a950-388855fed432" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Location of PowerPoint AutoRecover files</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/LocationOfPowerPointAutoRecoverFiles.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,90fc52c2-c73a-4709-900b-6f96fb4c9f1e.aspx</id>
    <published>2007-11-24T15:11:03.498125+01:00</published>
    <updated>2007-11-24T15:11:03.498125+01:00</updated>
    <category term="Personal" label="Personal" scheme="dasBlog" />
    <category term="Personal/Software" label="Personal/Software" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Not so long ago I've been called to my boss's office to prevent him losing unsaved
      work in a PowerPoint presentation. It turned out that when he tried to save the file
      to a new location the message box with the overwrite warning for some reason didn't
      render completely and it was impossible to close it. As it turned out at the end I
      could have just killed the application and restart it, since the AutoRecover feature
      kicked in and offered a version of the file with all changes applied.
   </p>
        <p>
      But just to be on the save side I wanted to copy the AutoRecover files to a save location
      before actually killing the application. But unlike Word or Excel where the location
      of these files is set in the options, PowerPoint does not have such an option. After
      some googling I finally stumbled across <a href="http://office.microsoft.com/en-us/help/HA101578851033.aspx">a
      page</a>, correctly stating that the files are stored in the %temp% folder and named
      ppt*.tmp. I decided to publish this info here just in case I need it again.
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=90fc52c2-c73a-4709-900b-6f96fb4c9f1e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Loop over files in directory from a batch file</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/LoopOverFilesInDirectoryFromABatchFile.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,6440be26-d6e9-4d14-91f2-6f1d9c2831bd.aspx</id>
    <published>2007-07-24T16:19:03.436375+02:00</published>
    <updated>2007-07-24T16:19:03.436375+02:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/Batch" label="Development/Batch" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Figuring this out took me much longer than it should. The following line in a batch
      file will execute a command for each file in a directory:
   </p>
        <div class="CodeFormatContainer">
          <pre class="csharpcode">
            <span class="kwrd">for</span> %%I <span class="kwrd">in</span> (C:\*.*) <span class="kwrd">do</span> echo
      %%~nxI</pre>
        </div>
        <p>
      I had to overcome two obstacles to make this work:
   </p>
        <ul>
          <li>
         When including the command in a batch file the % characters must be duplicated in
         comparison to the syntax for executing the command directly from the
         command line.</li>
          <li>
         The ~nx prefix to the variable name causes only the filename with extension to be
         used instead of the complete path.</li>
        </ul>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=6440be26-d6e9-4d14-91f2-6f1d9c2831bd" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Creating custom tasks for CruiseControl.NET</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/CreatingCustomTasksForCruiseControlNET.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,8e8055e2-dda6-43e2-850b-8a17419a94b2.aspx</id>
    <published>2007-07-24T13:57:26.7645+02:00</published>
    <updated>2007-07-24T13:57:26.7645+02:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/.NET" label="Development/.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Once you start putting <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">CruiseControl.NET</a> to
      production use you'll sooner or later encounter the need for custom build tasks. There's
      only a limited set of them in the package and <a href="http://confluence.public.thoughtworks.org/display/CCNET/Executable+Task">Executable
      Task</a> can only do so much. Unfortunately there is not much information available
      on development of custom tasks. Your best sources will be:
   </p>
        <ul>
          <li>
            <a href="http://confluence.public.thoughtworks.org/display/CCNET/Documentation">Online
         documentation</a> contains <a href="http://confluence.public.thoughtworks.org/display/CCNET/Custom+Builder+Plug-in">an
         article on the subject</a> describing the first steps to get you going. It should
         be your first stop.</li>
          <li>
         There's <a href="http://blogs.the-collins.net/Josh/archive/2007/04/01/AdventuresInCCNet.aspx">a
         high level architectural overview</a> of a simple task available at Josh's Blog.</li>
          <li>
         Lutz Roeder's <a href="http://www.aisto.com/roeder/dotnet/">Reflector for .NET</a> will
         be your best friend. The source of the tasks in ThoughtWorks.CruiseControl.Core will
         soon become your best resource.</li>
        </ul>
        <p>
      Apart from that I feel obliged to mention a few of the most important points I've
      come across during the development of a few custom tasks:
   </p>
        <ul>
          <li>
         ThoughtWorks.CruiseControl.Core.Util.ProcessExecutor is a nice little wrapper around
         System.Diagnostics.Process class you'll end up using quite a lot.</li>
          <li>
         You can add your own information to the build log by calling AddTaskResult on the
         IIntegrationResult instance passed to your ITask.Run method. There are two overloads
         available: one accepting a System.String and another one accepting ITaskResult to
         which you can pass a new FileTaskResult instance to quickly include a complete file.</li>
          <li>
         If you're doing any checkins to your source control system as a part of the build
         you should call the MarkStartTime method of your IIntegrationResult instance afterwards to
         prevent triggering another build of the same project by setting the last build start
         time after the last checkin time.</li>
          <li>
         Make sure you use a unique ReflectorType name for your task. The service will just
         silently fail to start in case of a duplicate value.</li>
        </ul>
        <p>
      This information should make your first attempts at making your own custom
      task a little easier.
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=8e8055e2-dda6-43e2-850b-8a17419a94b2" />
      </div>
    </content>
  </entry>
  <entry>
    <title>MSBuild.xsl problem in CruiseControl.NET 1.3</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/MSBuildxslProblemInCruiseControlNET13.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,20d7f883-4d11-478a-9d81-b69c38c0c43d.aspx</id>
    <published>2007-07-22T13:24:07.952+02:00</published>
    <updated>2007-07-22T13:27:09.85825+02:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/.NET" label="Development/.NET" scheme="dasBlog" />
    <category term="Downloads" label="Downloads" scheme="dasBlog" />
    <category term="Downloads/Sources" label="Downloads/Sources" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The 1.3.0.2918 build of <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">CruiseControl.NET</a> has
      an error in msbuild.xsl file which causes an XslLoadException to be thrown when trying
      to view the MSBuild output in the web dashboard. One of the users was nice enough
      to <a href="http://groups.google.com.ag/group/ccnet-user/browse_thread/thread/6ca4e259d91399ff#msg_4639bc18e08df384">describe
      the changes</a> to the file necessary to fix the problem. Unfortunately even the latest
      version of the file on the <a href="http://ccnetlive.thoughtworks.com/">CruiseControl.NET
      Live</a> site doesn't include the changes therefore I'm attaching the file to this
      post as convenience.
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=20d7f883-4d11-478a-9d81-b69c38c0c43d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Installing MSI packages from command line</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/InstallingMSIPackagesFromCommandLine.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,f888abb8-c481-41f5-8b91-aaa7957eb535.aspx</id>
    <published>2007-07-22T12:24:14.8895+02:00</published>
    <updated>2007-07-22T12:24:14.8895+02:00</updated>
    <category term="Personal" label="Personal" scheme="dasBlog" />
    <category term="Personal/Software" label="Personal/Software" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Although a MSI file can bi installed by double clicking on it in Explorer or by selecting
      install from the context menu, you might want to start from command line to include
      it in a script. This can be done by using the msiexec.exe utility. Although it's parameters
      are <a href="http://technet2.microsoft.com/windowsserver/en/library/9361d377-9011-4e21-8011-db371fa220ba1033.mspx?mfr=true">well</a><a href="http://helpnet.installshield.com/robo/projects/HelpLibDevStudio9/IHelpCmdLineMSI.htm">documented</a> I
      had to do some searching to find a way for setting a different installation directory
      than the default one in case the configuration forms are skipped with the /qb option.
      It can be done by setting the INSTALLDIR property to the desired value.
   </p>
        <p>
      As a future reference the following command line triggers the setup package to install
      into the specified directory without opening any additional configuration windows:
   </p>
        <div class="CodeFormatContainer">
          <pre class="csharpcode">msiexec /i MyMSI.msi /qb INSTALLDIR=<span class="str">"C:\Program
      Files\My Install Dir"</span></pre>
        </div>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=f888abb8-c481-41f5-8b91-aaa7957eb535" />
      </div>
    </content>
  </entry>
  <entry>
    <title>OCR with Microsoft Office Document Imaging</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/OCRWithMicrosoftOfficeDocumentImaging.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,ead407af-dbbb-4cbc-b826-b1934900aef8.aspx</id>
    <published>2007-06-02T10:39:34+02:00</published>
    <updated>2007-06-02T11:15:30.523125+02:00</updated>
    <category term="Development" label="Development" scheme="dasBlog" />
    <category term="Development/.NET" label="Development/.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      If you need cheap and simple OCR functionality <a href="http://msdn2.microsoft.com/en-us/library/aa203311(office.11).aspx">Microsoft
      Office Document Imaging Type Library</a> (MODI) is a nice option if its requirements
      (Microsoft Office 2003 or later) and limitations (limited language support) don't
      bother you. Here is a simple C# function that does OCR on the image with the specified
      path:
   </p>
        <div class="CodeFormatContainer">
          <pre class="csharpcode">
            <span class="kwrd">static</span>
            <span class="kwrd">string</span> OCR(<span class="kwrd">string</span> path)
      { MODI.Document doc = <span class="kwrd">new</span> MODI.Document(); doc.Create(path);
      doc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, <span class="kwrd">false</span>, <span class="kwrd">false</span>); <span class="kwrd">string</span> result
      = ((MODI.Image)doc.Images[0]).Layout.Text; System.Runtime.InteropServices.Marshal.ReleaseComObject(doc); <span class="kwrd">return</span> result;
      } </pre>
        </div>
        <p>
      However, there is another Microsoft Office object model related problem. For Office
      2003 users to be able to use your application, the MODI 11.0 (2003 version) must be
      referenced in the project and the release version of the application must be compiled
      on a machine with Office 2003 installed. In such a case VB6 still managed to compile
      the project on a machine with a newer version of Office installed, since the newer
      version of the type library was automatically used (MODI 12.0 for Office 2007 in this
      case). On the other hand strong type checking at compile time prevents that in C#.
   </p>
        <p>
      If you want to keep using Office 2007 and be able to compile such a project, the only
      solution is to install Microsoft Office Document Imaging as the only component of
      Office 2003 along the existing Office 2007 installation. Unfortunately this overwrites
      the Microsoft Office Document Image Writer printer driver from 2007 with the older
      version, therefore you'll have to start a lengthy process of repairing the Office
      2007 installation afterwards. And don't forget to apply all the service packs and
      updates for Office 2003 before that since this will also overwrite the printer driver
      and you'll have to repair Office 2007 once again. I learned that the hard way.
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=ead407af-dbbb-4cbc-b826-b1934900aef8" />
      </div>
    </content>
  </entry>
  <entry>
    <title>How to enable hibernation in Windows Vista</title>
    <link rel="alternate" type="text/html" href="http://www.damirscorner.com/HowToEnableHibernationInWindowsVista.aspx" />
    <id>http://www.damirscorner.com/PermaLink,guid,b56a5678-74e2-49c0-9d66-9a7148000244.aspx</id>
    <published>2007-05-21T21:45:17.265625+02:00</published>
    <updated>2007-05-21T21:45:17.265625+02:00</updated>
    <category term="Personal/Software" label="Personal/Software" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Windows Vista unlike the previous versions doesn't have an option to enable or disable
      hibernation in the <font face="Courier New">Power Options</font> of the <font face="Courier New">Control
      Panel</font>. Strangely, if you search for <font face="Courier New">hibernation</font> in <font face="Courier New">Control
      Panel</font> the <font face="Courier New">Turn hibernation on or off </font>option
      will be found but it will only open the <font face="Courier New">Edit Plan Settings</font> dialog
      without hibernation available if it is already disabled. Therefore, if you end up
      with disabled hibernation as I did (probably due to the <font face="Courier New">Hibernation
      File Cleaner</font> option of the <font face="Courier New">Disk Cleanup</font> tool)
      the only way to turn it back on is to open a command prompt and run
   </p>
        <p>
          <font face="Courier New">powercfg -H on</font>
        </p>
        <p>
      This will make the hibernation reappear in all the shutdown menus and power button
      combos.
   </p>
        <img width="0" height="0" src="http://www.damirscorner.com/aggbug.ashx?id=b56a5678-74e2-49c0-9d66-9a7148000244" />
      </div>
    </content>
  </entry>
</feed>