4 Replies - 5187 Views - Last Post: 12 December 2011 - 10:51 AM

#1 elesbb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 06-December 11

show desktop on windows Mobile

Posted 08 December 2011 - 01:23 PM

I am trying to show the desktop on a windows mobile 6.5.5 device . I have this much .

using Shell32;
            Shell32.ShellClass shell = new Shell32.ShellClass();
            shell.MinimizeAll();


this is executed after taping a button .

everything gets compiled just fine but when i emulate the program i get this error upon tapping the button .

COM object with CLSID '{13709620-C279-11CE-A49E-444553540000}' cannot be created due to the following error: Class not registered 


im not exactly sure what this means . ive googled my little heart out . and all i found was that i had to implement the Shell32.dll which i did .

I appologize for any things ive done wrong in my posting . but im lost .

thanks everyone for your help !

Is This A Good Question/Topic? 0
  • +

Replies To: show desktop on windows Mobile

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: show desktop on windows Mobile

Posted 08 December 2011 - 01:37 PM

I found this link over at StackOverflow which seems to do exactly what you want, but uses PInvoke instead.

http://stackoverflow...dows-in-c-sharp

This was the code that was posted as the answer...

using System;
using System.Runtime.InteropServices;

namespace ConsoleApplication1 {
class Program {
    [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true)]
    static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);

    const int WM_COMMAND = 0x111;
    const int MIN_ALL = 419;
    const int MIN_ALL_UNDO = 416;

    static void Main(string[] args) {
        IntPtr lHwnd = FindWindow("Shell_TrayWnd", null);
        SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL, IntPtr.Zero); 
        System.Threading.Thread.Sleep(2000);
        SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL_UNDO, IntPtr.Zero);
    }
}
}


Was This Post Helpful? 0
  • +
  • -

#3 elesbb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 06-December 11

Re: show desktop on windows Mobile

Posted 08 December 2011 - 02:09 PM

View Posteclipsed4utoo, on 08 December 2011 - 01:37 PM, said:

I found this link over at StackOverflow which seems to do exactly what you want, but uses PInvoke instead.

http://stackoverflow...dows-in-c-sharp

This was the code that was posted as the answer...

using System;
using System.Runtime.InteropServices;

namespace ConsoleApplication1 {
class Program {
    [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true)]
    static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);

    const int WM_COMMAND = 0x111;
    const int MIN_ALL = 419;
    const int MIN_ALL_UNDO = 416;

    static void Main(string[] args) {
        IntPtr lHwnd = FindWindow("Shell_TrayWnd", null);
        SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL, IntPtr.Zero); 
        System.Threading.Thread.Sleep(2000);
        SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL_UNDO, IntPtr.Zero);
    }
}
}



thanks , just a little confused , im using Visual Studio 2008 C# . i visited the link and it says C++ ?

PS Sorry for not posting in the right section . i posted in C# because my phone isnt technically a "Windows Phone" its windows mobile . but thanks i know now .
Was This Post Helpful? 0
  • +
  • -

#4 elesbb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 06-December 11

Re: show desktop on windows Mobile

Posted 08 December 2011 - 03:16 PM

Copied the text into Visual Studio and i compiled and i get this error when trying to run .

Can't find PInvoke DLL 'user32.dll'

Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: show desktop on windows Mobile

Posted 12 December 2011 - 10:51 AM

I found this on another forum.

Quote

user32.dll doesn't exist in CE. Use coredll.dll


So you would change these two lines...
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
[DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true)]



to

[DllImport("coredll.dll", EntryPoint = "FindWindow", SetLastError = true)]
[DllImport("coredll.dll", EntryPoint = "SendMessage", SetLastError = true)]



See if that works for you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1