Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.07.25;
Скачать: CL | DM;

Вниз

ico из exe   Найти похожие ветки 

 
Foger   (2004-06-06 20:02) [0]

не скажет ли мне кто ,как содрать ico из exe.Спасибо


 
parovoZZ ©   (2004-06-06 21:04) [1]

Вот нашёл на своём винте:
Сначала в разделе interface пишем такой код:

type ThIconArray = array[0..0] of hIcon;
type PhIconArray = ^ThIconArray;

function ExtractIconExA(lpszFile: PAnsiChar;
 nIconIndex: Integer;
 phiconLarge : PhIconArray;
 phiconSmall: PhIconArray;
 nIcons: UINT): UINT; stdcall;
 external "shell32.dll" name "ExtractIconExA";

function ExtractIconExW(lpszFile: PWideChar;
 nIconIndex: Integer;
 phiconLarge: PhIconArray;
 phiconSmall: PhIconArray;
 nIcons: UINT): UINT; stdcall;
 external "shell32.dll" name "ExtractIconExW";

function ExtractIconEx(lpszFile: PAnsiChar;
 nIconIndex: Integer;
 phiconLarge : PhIconArray;
 phiconSmall: PhIconArray;
 nIcons: UINT): UINT; stdcall;
 external "shell32.dll" name "ExtractIconExA";



Затем по нажатию на кнопку:

procedure TForm1.Button1Click(Sender: TObject);
var
 NumIcons: integer;
 pTheLargeIcons: phIconArray;
 pTheSmallIcons: phIconArray;
 LargeIconWidth: integer;
 SmallIconWidth: integer;
 SmallIconHeight: integer;
 i: integer;
 TheIcon: TIcon;
 TheBitmap: TBitmap;
begin
 NumIcons :=
 ExtractIconEx("C:\Program Files\Borland\Delphi 3\BIN\delphi32.exe",
   -1, nil, nil, 0);
 if NumIcons > 0 then
 begin
   LargeIconWidth := GetSystemMetrics(SM_CXICON);
   SmallIconWidth := GetSystemMetrics(SM_CXSMICON);
   SmallIconHeight := GetSystemMetrics(SM_CYSMICON);
   GetMem(pTheLargeIcons, NumIcons * sizeof(hIcon));
   GetMem(pTheSmallIcons, NumIcons * sizeof(hIcon));
   FillChar(pTheLargeIcons^, NumIcons * sizeof(hIcon), #0);
   FillChar(pTheSmallIcons^, NumIcons * sizeof(hIcon), #0);
   ExtractIconEx("C:\Program Files\Borland\Delphi 3\BIN\delphi32.exe",
     0, pTheLargeIcons, pTheSmallIcons, numIcons);
   {$IFOPT R+}
   {$DEFINE CKRANGE}
   {$R-}
   {$ENDIF}
   for i := 0 to (NumIcons - 1) do
   begin
     DrawIcon(Form1.Canvas.Handle, i * LargeIconWidth, 0, pTheLargeIcons^[i]);
     TheIcon := TIcon. Create;
     TheBitmap := TBitmap.Create;
     TheIcon.Handle := pTheSmallIcons^[i];
     TheBitmap.Width := TheIcon.Width;
     TheBitmap.Height := TheIcon.Height;
     TheBitmap.Canvas.Draw(0, 0, TheIcon);
     TheIcon.Free;
     Form1.Canvas.StretchDraw(Rect(i * SmallIconWidth,
       100, (i + 1) * SmallIconWidth, 100 + SmallIconHeight), TheBitmap);
     TheBitmap.Free;
   end;
   {$IFDEF CKRANGE}
   {$UNDEF CKRANGE}
   {$R+}
   {$ENDIF}
   FreeMem(pTheLargeIcons, NumIcons * sizeof(hIcon));
   FreeMem(pTheSmallIcons, NumIcons * sizeof(hIcon));
 end;
end;




 
grom   (2004-06-06 21:17) [2]

Image1.Picture.Icon.Handle:=ExtractIcon(hInstance,PChar("D:\ops.exe"),Ico);


 
Wiz@rd   (2004-06-08 16:53) [3]

SHGetFileInfo там можно иконку тоже получить



Страницы: 1 вся ветка

Текущий архив: 2004.07.25;
Скачать: CL | DM;

Наверх




Память: 0.45 MB
Время: 0.023 c
3-1088659685
kalishenko
2004-07-01 09:28
2004.07.25
Pervasive 2000i & DISTINCT


1-1089358029
Sur
2004-07-09 11:27
2004.07.25
JPG+EOF+SomeText


3-1088139310
nik7777
2004-06-25 08:55
2004.07.25
Репликация между серверами FireBird 1.0.2


14-1088762602
Snip
2004-07-02 14:03
2004.07.25
Облом с интернетом


1-1089296357
SergP
2004-07-08 18:19
2004.07.25
ListView. Как выыключить автосмену выбраного элемента





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский