PhotoTagStudio 0.6 released

Tags: , ,
No Comments »

Today I released the new version of PhotoTagStudio with some new features (Copy photos from memory card, Macro and Plugins).

See http://phototagstudio.irgendwie.net/

msi-Installer created with Visual Studio and the RemovePreviousVersions-Option

Tags: , ,
1 Comment »

[Edit: this seems to be solved in Visual Studio 2008. See this article]

In theory if you create a setup project within Visual Studio, you can set the RemovePreviousVersions to force the created setup to uninstall all previous versions of the same software already install on the target computer. This is a very useful option, but it does not work under all circumstances. But before I go into the problems a brief overview how it should work:

Besides the RemovePreviousVersions flag there are two further properties: UpgradeCode and ProductCode. The UpgradeCode must be the same for all setup projects (that is for the old versions and for the new version). The installer uses this UpgradeCode to detect an older version of the software. The ProductCode must be different for every version, this is uses by the installer to detect different versions of the same software . If you change the Version of an installer Visual Studio creates a new ProductCode.

This works the way described here in the same way described in the product documentation as long as you do not use a Version number below 1.0. If you name your beta and prerelease version something like 0.5 the installer does not recognize an previous version and will not uninstall it, but installs the new version side by side which can be a problem for you installation e.g. if it will be installed in the same directory.

Unfortunately this seem to be a known issue since 2004 or earlier and is not fixed in Visual Studio 2005. The installer looks only for previous Versions greater or equal 1.0 but not for versions less than 1.0.

But there is a workaround. You have to patch the MinVersion in the created msi-file with a tool called orca.exe.

  1. Download the Windows Platform SDK – about 400 MB
  2. Install it – Full install is about 1 GB but you only need the MSI-SDK parts, so choose the custom installation.
  3. In the directory of the SDK you will find an orca.msi – install it
  4. Start the orca.exe and open your created msi
  5. Got the Upgrade-Table
  6. Look for the 1.0.0.0 in the VersionMin-field and change it to somethink like 0.1.0.0
  7. Save the changes to the msi

iTunes, iPod und last.fm

Tags: ,
No Comments »

Wie scrobbt man Songs aus iTunes und dem iPod nach last.fm?
Ich habe mich etwas umgeschaut und bisher keine zufriedenstellende Lösung für mich gefunden.

Der orginal last.fm Player mit iPod und iTunes Plugin
http://www.lastfm.de/download/
Ist eine nette Software, die sich mit iTunes startet. Leider läuft permanent im Hintergrund in Helper der 10 MB RAM braucht. Der Player benötigt weitere 15 MB, ist aber sehr hübsch, vor dem übertragen von Songs es iPods kann man einige Songs ausschließen. Außerdem werden sehr gute Informationen zu dem gerade gespielten Song angezeigt.
Leider funktioniert das scrobben vom iPod nur wenn dieser auf automatisch synchronisieren steht (und das tut er bei mir nicht).
Unter Vista sollte man die Beta Version verwenden, da diese nicht bei jedem iTunes start nach Admin rechten für den Player fragt (Stichwort UAC):

iScrobbler For Windows
http://xurble.org/projects/iScrobbler
Habe ich diesmal nicht getestet, da dieses Plugin eh nicht mit dem iPod umgehen kann, der Vorteil ist, dass es keine riesige Software ist, die ständig läuft, sondern nur ein kleines Plugin in iTuens.

jscrob2 – iTunes plug-in w/ iPod sync support & real-time submissions
http://www.lastfm.de/forum/827/_/47398/1
Dies wäre mein Favorit, es ist wie iScrobbler ein leichtgewichtiges Plugin für iTunes und kann auch vom iPod scrobben. Allerdings auch nur wenn man automatisch mit dem iPod synchronisiert. Allerdings geht es hier anscheinend anders vor als der last.fm Player. Es betrachtet die Playlist „Recently Played“ in iTunes. Man muss eben sorgen, dass die auf dem iPod gespielten Songs hierlanden. Dies tun sie aber nur, wenn man ihn mit iTunes synct. Dies kann man aber auch erreichen, indem man nur spezielle Playlists abgleicht. Müsste sehr gut funktionieren, aber leider auch nicht für mich, da die Musik, die ich höre, gar nicht in meinem normalem iTunes enthalten ist.
Im Forum ist sehr genau erklärt, wie man die Playlist anlegt usw.

iSproggler
http://www.lastfm.de/group/iSproggler
Die s scheint die größte und am meisten verbreitetste Software zu sein, was ich allerdings nicht verstehen kann. Sie belegt permanent 40 MB Ram auch wenn man gar kein iTunes benutzt, was ich selbst bei 2 GB RAM als sehr unnötig erachte. Außerdem registriert sie sich bei iTunes, so dass dieses immer einen Fehlermeldung beim beenden ausgibt, weil noch einen andere Anwendung verbunden ist. Das ist auch sehr nervig.
Zu allem Überfluss findet man übrigens nirgendwo einen Downloadlink. Dazu muss man ins iSproggler Forum gehen und das darf man erst wenn man der last.fm Gruppe beigetreten ist – schlechtes Marketing!

Ich habe leider keine Möglichkeit gefunden, die Songs, die ich auf dem iPod höre (manuelles Pflegen der Musik) zu scrobben.

Windows shell32.dll SHFileOperation marshalling and hNameMappings

Tags:
2 Comments »

For my Software PhotoTagStudio I implemented a new feature to copy jpg-files from a memory card to the disk. I wanted to use that fancy Windows XP explorer copy dialog with the papers flying from one folder to another. And where I get the (more or less accurate) time estimation for free.

Searching the web I found the shell32.dll and the SHFileOperation function. This function does exactly what I need and on www.codeproject.com you can find a great article by arikp on how to address system32.dll from .net. arikp included sourcecode so you find everything you need to call the system32.dll functions from .net. Unfortunately two little features didn’t not work as expected:

hNameMappings is rarely used and can help only if I’m interesting in the new names the user had to give during the operation…

(but did not work in the ShellApi.cs)

…and finally lpszProgressTitle, If we set the flag FOF_SIMPLEPROGRESS, the progress dialog box does not present the file names and is supposed to present the text of this parameter. When I test this function I couldn’t get this parameter to show, it didn’t show the file names with the SIMPLEPROGRESS flag but it did not show the title parameter. What can I say, strange.

(did not work as well)

But I have to know the new names and thus had to get the NameMappings-thing working all by myself (I could not find a solution anywhere in the web). So I asked a good friend of mine, Wolfram Bernhardt, who subsequently did most of the following work:

He found a problem in the SHFILEOPSTRUCT:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SHFILEOPSTRUCT
{
    public IntPtr hwnd;
    public UInt32 wFunc;
    public IntPtr pFrom;
    public IntPtr pTo;
    public UInt16 fFlags;
    public Int32 fAnyOperationsAborted;
    public IntPtr hNameMappings;
    [MarshalAs(UnmanagedType.LPWStr)]
    public String lpszProgressTitle;
}

When marshalling this from .net to unsafe/native each element of the struct is stored at an address that is an multiple of 4. (This is the default for .net on Win32 for performance reasons). This leads to some unused bytes – i.e. fFlags is only 16 bit width and the next parameter should not leave a space of two byte.

The functions of shell32.dll are old fashion and do not waste any space. So they read wrong values after fFlags. The fAnyOperationsAborted wasn’t harmed that much and it’s value wasn’t checked too carefully in my application. But the hNameMappings-Pointer went totally wrong.

To change this behaviour you just have to add the Pack=2 parameter to the attribute:
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]

After this little change hNameMappings is marshalled back correctly and points to a mapping-structue. As a “side-effect” the lpszProgressTitle is now shown as expected – at least on Win XP, Vista seems to ignore this string. Obviously MS has changed this function of shell32.dll. But the more important functions work as desired.

To get the new filenames you have to set the Flags FOF_WANTMAPPINGHANDLE and FOF_RENAMEONCOLLISION. The latter allows the function to (automatically) rename files during copying. If a filename already exists, the new copy is renamed to something like “Copy of [filename]“. On a Windows Vista machine you don’t need the FOF_RENAMEONCOLLISION flag, because the user can choose the new option “Keep both the original file and the copy? in the dialog that asks to override existing files. In both cases the hNameMappings is filled with a pointer to a list of Mapping objects that contain the original and the new filenames.

To get the list from the hNameMappings Pointer you have to implement two more structs and Wolfram did it, too. He added a new property NameMappings to the ShellFileOperation Class. (For details see the source code of the changes ShellLib.)

With the following download we provide an updated Version of the ShellLib with the described changes. For more information please refer to the original article on The Code Project and take a look on the demo code over there.

The enhanced ShellLib Code

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in