Check-in [7af134b435]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use ExtractIcon to read an executable's icon.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7af134b4352e5a68b73e987db2d64ffb2982803b
User & Date: tinus 2015-11-21 01:46:06
Context
2015-11-23
20:36
Expanded plans: add an about dialog, and set up a thread to keep track of tasks, and execute them. check-in: 3072d771a0 user: tinus tags: trunk
2015-11-21
01:46
Use ExtractIcon to read an executable's icon. check-in: 7af134b435 user: tinus tags: trunk
01:25
Make icon retrieval more robust. Always fetch the small icon. Reduce the timeout to 10 seconds. check-in: 6af77a0ede user: tinus tags: trunk
Changes

Changes to src/VCSInfoMenuWzrd.pas.

429
430
431
432
433
434
435

436
437

438
439
440




441
442
443

444
445
446
447
448
449
450
451
452
453


454
455
456
457
458
459
460
  function AddExeIcon(const ExeName: string): Integer;
  var
    ExePath: string;
    PFileName: PChar;
    IconHandle: HICON;
    Icon: TIcon;
    FileInfo: TSHFileInfo;

  begin
    IconHandle := 0;

    ExePath := StringOfChar(#0, 255);
    SetLength(ExePath, SearchPath(nil, PChar(ExeName), nil, Length(ExePath), PChar(ExePath), PFileName));
    if ExePath <> '' then begin




      FileInfo := Default(TSHFileInfo);
      if SHGetFileInfo(PChar(ExePath), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON or SHGFI_SMALLICON) <> 0 then
        IconHandle := FileInfo.hIcon;

    end;
    if IconHandle = 0 then
      IconHandle := LoadIcon(0, IDI_APPLICATION);
    Icon := TIcon.Create;
    try
      Icon.Handle := IconHandle;
      Result := Services.ImageList.AddIcon(Icon);
    finally
      Icon.Free;
    end;


  end {AddExeIcon};
  { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
  function AddButtonMenuItem(const Button: TToolButton; ImageIndex: integer; Caption: string): TMenuItem;
  begin
    Result := TMenuItem.Create(Button.DropdownMenu);
    Result.Caption := Caption;
    Result.ImageIndex := ImageIndex;







>


>



>
>
>
>
|
|
|
>










>
>







429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
  function AddExeIcon(const ExeName: string): Integer;
  var
    ExePath: string;
    PFileName: PChar;
    IconHandle: HICON;
    Icon: TIcon;
    FileInfo: TSHFileInfo;
    ShouldDestroy: Boolean;
  begin
    IconHandle := 0;
    ShouldDestroy := False;
    ExePath := StringOfChar(#0, 255);
    SetLength(ExePath, SearchPath(nil, PChar(ExeName), nil, Length(ExePath), PChar(ExePath), PFileName));
    if ExePath <> '' then begin
      IconHandle := ExtractIcon(HInstance, PChar(ExePath), 0);
      if IconHandle <> 0 then begin
        ShouldDestroy := True;
      end else begin
        FileInfo := Default(TSHFileInfo);
        if SHGetFileInfo(PChar(ExePath), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON or SHGFI_SMALLICON) <> 0 then
          IconHandle := FileInfo.hIcon;
      end;
    end;
    if IconHandle = 0 then
      IconHandle := LoadIcon(0, IDI_APPLICATION);
    Icon := TIcon.Create;
    try
      Icon.Handle := IconHandle;
      Result := Services.ImageList.AddIcon(Icon);
    finally
      Icon.Free;
    end;
    if ShouldDestroy then
      DestroyIcon(IconHandle);
  end {AddExeIcon};
  { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
  function AddButtonMenuItem(const Button: TToolButton; ImageIndex: integer; Caption: string): TMenuItem;
  begin
    Result := TMenuItem.Create(Button.DropdownMenu);
    Result.Caption := Caption;
    Result.ImageIndex := ImageIndex;