Sebbis Blog

Schlagwort: Managed Code

  • Windows Mobile Cab File Installer (via autorun.exe / Managed Code)

    Eigentlich eine ganz simple Sache, aber irgendwie findet man darüber so leicht nichts. Hier also der Sourcecode einer autorun.exe für Windows Mobile (5.0 aufwärts) in C#. Die Datei kommt für Geräte mit ARM-Prozessor in den Unterornder „2577“ auf der Speicherkarte und wird beim Einstecken der Karte automatisch aufgerufen. Was sie macht? Die erst beste CAB-Datei aus dem Rootverzeichnis der Speicherkarte aufrufen bzw. installieren.

    Vielleicht hilft’s ja wem …

    [sourcecode language=’csharp‘]
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using System.Diagnostics;

    namespace MyInstaller
    {
    class Program
    {
    static void Main(string[] args)
    {
    if (args.Length > 0 && args[0] == „install“)
    {
    // Get the code directory of this application
    string FullPath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
    // Split the path and find the storage card name used
    string[] Tokens = FullPath.Split(‚\\‘);
    if (Tokens.Length < 2) { MessageBox.Show("This application should be started by the system"); return; } string StorageCardName = Tokens[Tokens.Length - 2]; string[] CabFiles = Directory.GetFiles(Path.DirectorySeparatorChar + StorageCardName, "*.cab"); if (CabFiles.Length == 0) { MessageBox.Show("Couldn't find installable CAB-file on the storage card (" + Path.DirectorySeparatorChar + StorageCardName + ")"); return; } string FirstCabFile = CabFiles[0]; Process.Start(FirstCabFile, ""); } } } } [/sourcecode] via Marcus Perryman (habe seine Version zur Installation von Einstellungen angepasst und eine Ewigkeit gebraucht sein Blogpost zu finden)