C# SendMessage(...) question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nidhi

    C# SendMessage(...) question

    Hi,

    I am trying to write code to retrieve the small icon for an
    application in C#. I am using SendMessage with WM_GETICON for this
    purpose but the return value I get is 0. I don't understand this. Is
    that expected? What am I doing wrong?
    Any help would be appreciated. Here is the snippet of code that I am
    using -

    [DllImport("user 32")] public static extern int SendMessage(int
    hwnd,int msg,int wparam,int lparam);

    Process p = Process.GetProc essById(a.getPI D()); //the requisite process and
    //the value returned is valid
    IntPtr hwnd = p.MainWindowHan dle;
    int icn = SendMessage((in t)hwnd,127,0,0) ; //I realize WM_GETICON = 127

    Thanks!
    Nidhi
  • MagicAxe via DotNetMonster.com

    #2
    Re: C# SendMessage(... ) question

    Just try this :

    int WM_GETICON = 0x7F;
    int WM_SETICON = 0x80;
    int ICON_SMALL = 0; //(16x16)
    int ICON_BIG = 1; //(32x32)

    IntPtr handle = pro.MainWindowH andle;
    int IconHandle = SendMessage(han dle.ToInt32(),W M_GETICON,ICON_ SMALL -or- ICON_BIG,0);
    Icon icn = Icon.FromHandle (new IntPtr(IconHand le));

    Note : I can't retrieve the most icon's handle.

    - Good Kiss from Switzerland -

    --
    Message posted via http://www.dotnetmonster.com

    Comment

    Working...