By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,457 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,457 IT Pros & Developers. It's quick & easy.

C# SendMessage(...) question

P: n/a
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("user32")] public static extern int SendMessage(int
hwnd,int msg,int wparam,int lparam);

Process p = Process.GetProcessById(a.getPID()); //the requisite process and
//the value returned is valid
IntPtr hwnd = p.MainWindowHandle;
int icn = SendMessage((int)hwnd,127,0,0); //I realize WM_GETICON = 127

Thanks!
Nidhi
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Just try this :

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

IntPtr handle = pro.MainWindowHandle;
int IconHandle = SendMessage(handle.ToInt32(),WM_GETICON,ICON_SMALL -or- ICON_BIG,0);
Icon icn = Icon.FromHandle(new IntPtr(IconHandle));

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

- Good Kiss from Switzerland -

--
Message posted via http://www.dotnetmonster.com
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.