Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

get icon from exe.real?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-27-2009, 12:52 PM
Byak@'s Avatar
Basic4ppc Veteran
 
Join Date: Jul 2008
Posts: 416
Send a message via ICQ to Byak@
Awards Showcase
Beta Tester 
Total Awards: 1
Default get icon from exe.real?

if in basic4ppc we have IconList may be it's real to get the icon from exe?
__________________
I'll Kill you, I'll Crash you, I'll never be yours!
--------------------------------------------------
Qtek s110; o2 XDA Flame; Nokia E63 red;
ASUS Eee PC 901 (Windows XP sp3) + TouchScreen;
Reply With Quote
  #2 (permalink)  
Old 02-27-2009, 05:51 PM
Byak@'s Avatar
Basic4ppc Veteran
 
Join Date: Jul 2008
Posts: 416
Send a message via ICQ to Byak@
Awards Showcase
Beta Tester 
Total Awards: 1
Default

what i'm find for c#
Code:
<font color="blue"> using </font>System;<font color="blue">using </font>System.Drawing;<font color="blue">using </font>System.Runtime.InteropServices;<font color="blue">using </font>System.IO;
<font color=
"blue">class </font>Program<font color="#454545">{</font><font color="blue">static </font><font color="blue">void </font>Main<font color="#454545">()</font><font color="#454545">    {</font><font color="green">// например, получаем иконку для PDF</font><font color="green">        // имя файла - от балды, главное это расширение</font><font color="blue">string </font>fileName = <font color="seagreen">"bla-bla-bla.pdf"</font>;
        <font color=
"green">// вся кухня - здесь</font>Shell32.SHFILEINFO shfi = <font color="blue">new </font>Shell32.SHFILEINFO<font color="#454545">()</font>;        Shell32.SHGetFileInfo<font color="#454545">(</font>fileName, Shell32.FILE_ATTRIBUTE_NORMAL, <font color="blue">ref </font>shfi,             <font color="#454545">(</font><font color="blue">uint</font><font color="#454545">)</font>Marshal.SizeOf<font color="#454545">(</font>shfi<font color="#454545">)</font>, Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES | Shell32.SHGFI_LARGEICON<font color="#454545">)</font>;        Icon icon = <font color="#454545">(</font>Icon<font color="#454545">)</font>Icon.FromHandle<font color="#454545">(</font>shfi.hIcon<font color="#454545">)</font>.Clone<font color="#454545">()</font>;        User32.DestroyIcon<font color="#454545">(</font>shfi.hIcon<font color="#454545">)</font>;
        <font color=
"green">// теперь можем, например, сохранить в bmp</font>icon.ToBitmap<font color="#454545">()</font>.Save<font color="#454545">(</font>@<font color="seagreen">"c:\pdf_icon.bmp"</font><font color="#454545">)</font>;    <font color="#454545">}</font><font color="#454545">}</font>

<font color=
"blue">public </font><font color="blue">class </font>Shell32<font color="#454545">{</font><font color="blue">public </font><font color="blue">const </font><font color="blue">int </font>MAX_PATH = 256;    <font color="#454545">[</font>StructLayout<font color="#454545">(</font>LayoutKind.Sequential<font color="#454545">)]</font><font color="blue">public </font><font color="blue">struct </font>SHITEMID    <font color="#454545">{</font><font color="blue">public </font><font color="blue">ushort </font>cb;        <font color="#454545">[</font>MarshalAs<font color="#454545">(</font>UnmanagedType.LPArray<font color="#454545">)]</font><font color="blue">public </font><font color="blue">byte</font><font color="#454545">[] </font>abID;    <font color="#454545">}</font>
<font color=
"#454545">    [</font>StructLayout<font color="#454545">(</font>LayoutKind.Sequential<font color="#454545">)]</font><font color="blue">public </font><font color="blue">struct </font>ITEMIDLIST    <font color="#454545">{</font><font color="blue">public </font>SHITEMID mkid;    <font color="#454545">}</font>
<font color=
"#454545">    [</font>StructLayout<font color="#454545">(</font>LayoutKind.Sequential<font color="#454545">)]</font><font color="blue">public </font><font color="blue">struct </font>SHFILEINFO    <font color="#454545">{</font><font color="blue">public </font><font color="blue">const </font><font color="blue">int </font>NAMESIZE = 80;        <font color="blue">public </font>IntPtr hIcon;        <font color="blue">public </font><font color="blue">int </font>iIcon;        <font color="blue">public </font><font color="blue">uint </font>dwAttributes;        <font color="#454545">[</font>MarshalAs<font color="#454545">(</font>UnmanagedType.ByValTStr, SizeConst = MAX_PATH<font color="#454545">)]</font><font color="blue">public </font><font color="blue">string </font>szDisplayName;        <font color="#454545">[</font>MarshalAs<font color="#454545">(</font>UnmanagedType.ByValTStr, SizeConst = NAMESIZE<font color="#454545">)]</font><font color="blue">public </font><font color="blue">string </font>szTypeName;    <font color="#454545">}</font>;
    <font color=
"blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_ICON = 0x000000100;     <font color="green">// get icon</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_DISPLAYNAME = 0x000000200;     <font color="green">// get display name</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_TYPENAME = 0x000000400;     <font color="green">// get type name</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_ATTRIBUTES = 0x000000800;     <font color="green">// get attributes</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_ICONLOCATION = 0x000001000;     <font color="green">// get icon location</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_EXETYPE = 0x000002000;     <font color="green">// return exe type</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_SYSICONINDEX = 0x000004000;     <font color="green">// get system icon index</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_LINKOVERLAY = 0x000008000;     <font color="green">// put a link overlay on icon</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_SELECTED = 0x000010000;     <font color="green">// show icon in selected state</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_ATTR_SPECIFIED = 0x000020000;     <font color="green">// get only specified attributes</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_LARGEICON = 0x000000000;     <font color="green">// get large icon</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_SMALLICON = 0x000000001;     <font color="green">// get small icon</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_OPENICON = 0x000000002;     <font color="green">// get open icon</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_SHELLICONSIZE = 0x000000004;     <font color="green">// get shell size icon</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_PIDL = 0x000000008;     <font color="green">// pszPath is a pidl</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_USEFILEATTRIBUTES = 0x000000010;     <font color="green">// use passed dwFileAttribute</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_ADDOVERLAYS = 0x000000020;     <font color="green">// apply the appropriate overlays</font><font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>SHGFI_OVERLAYINDEX = 0x000000040;     <font color="green">// Get the index of the overlay</font>
<font color=
"blue">public </font><font color="blue">const </font><font color="blue">uint </font>FILE_ATTRIBUTE_DIRECTORY = 0x00000010;    <font color="blue">public </font><font color="blue">const </font><font color="blue">uint </font>FILE_ATTRIBUTE_NORMAL = 0x00000080;
    <font color=
"#454545">[</font>DllImport<font color="#454545">(</font><font color="seagreen">"Shell32.dll"</font><font color="#454545">)]</font><font color="blue">public </font><font color="blue">static </font><font color="blue">extern </font>IntPtr SHGetFileInfo<font color="#454545">(</font><font color="blue">string </font>pszPath,        <font color="blue">uint </font>dwFileAttributes,        <font color="blue">ref </font>SHFILEINFO psfi,        <font color="blue">uint </font>cbFileInfo,        <font color="blue">uint </font>uFlags        <font color="#454545">)</font>;<font color="#454545">}</font>
<font color=
"blue">public </font><font color="blue">class </font>User32<font color="#454545">{</font><font color="#454545">    [</font>DllImport<font color="#454545">(</font><font color="seagreen">"User32.dll"</font><font color="#454545">)]</font><font color="blue">public </font><font color="blue">static </font><font color="blue">extern </font><font color="blue">int </font>DestroyIcon<font color="#454545">(</font>IntPtr hIcon<font color="#454545">)</font>;<font color="#454545">}</font>
and it
Code:
<font color="blue">public </font><font color="blue">static </font>Icon ExtractAssociatedIcon <font color="#454545">(</font>
<font color=
"blue">string </font>filePath
<font color=
"#454545">)</font>
Code:
Icon ico = Icon.ExtractAssociatedIcon<font color="#454545">(</font>@<font color="seagreen">"C:\WINDOWS\system32\notepad.exe"</font><font color="#454545">)</font>;
__________________
I'll Kill you, I'll Crash you, I'll never be yours!
--------------------------------------------------
Qtek s110; o2 XDA Flame; Nokia E63 red;
ASUS Eee PC 901 (Windows XP sp3) + TouchScreen;
Reply With Quote
  #3 (permalink)  
Old 02-27-2009, 06:52 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

You can probably get the icon with the Door library but what are you going to assign it to in Basic4ppc
Reply With Quote
  #4 (permalink)  
Old 02-28-2009, 10:38 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Byak@ View Post
get the icon from exe?
Like this, which only works in .NET 2.0 or later and only on the desktop. Obj1 is a Door library Object.
Code:
Obj1.New1(False)
' create a new empty Icon
Obj1.CreateNew("System.Drawing.Icon" & Obj1.System_Drawing)
' get an Icon from a file
Obj1.Value = Obj1.RunMethod2("ExtractAssociatedIcon","C:\WINDOWS\system32\notepad.exe""System.String")
' add it to an ControlsExDesktop IconList
IconList.AddIcon(Obj1.Value)
' or turn it into a bitmap
Image1.Image = Obj1.RunMethod("ToBitmap")    
' alternatively
Image1.Image = IconList.ItemBitmap(0)
Reply With Quote
  #5 (permalink)  
Old 03-01-2009, 10:39 AM
Byak@'s Avatar
Basic4ppc Veteran
 
Join Date: Jul 2008
Posts: 416
Send a message via ICQ to Byak@
Awards Showcase
Beta Tester 
Total Awards: 1
Default

agraham big thanks!
__________________
I'll Kill you, I'll Crash you, I'll never be yours!
--------------------------------------------------
Qtek s110; o2 XDA Flame; Nokia E63 red;
ASUS Eee PC 901 (Windows XP sp3) + TouchScreen;
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
New icon contest Erel Announcements 24 02-03-2009 08:11 PM
A new icon, seriously N1c0_ds Basic4ppc Wishlist 4 11-25-2008 04:52 AM
Creating process-real!!! Byak@ Code Samples & Tips 6 10-06-2008 02:59 PM
Icon?? tvrman Chit Chat 7 07-03-2007 09:00 PM
Icon association Cableguy Questions (Windows Mobile) 9 05-22-2007 08:43 PM


All times are GMT. The time now is 01:18 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0