CD Rom'a takılan cd'nin iconunun alınması

Yazdığınız makaleleri ve üyelerimizin işine yarayacağını düşündüğünüz kodlarınızı gönderebilirsiniz. Bu foruma soru sormayın!
Cevapla
csyasar
Üye
Mesajlar: 646
Kayıt: 25 Şub 2004 10:14
Konum: Tokat

CD Rom'a takılan cd'nin iconunun alınması

Mesaj gönderen csyasar »

Kod: Tümünü seç

function GetCDIcon(Drive: Char): TIcon;
var
  ico: TIcon;
  ini: TIniFile;
  s, p: string;
  i, j: Integer;
begin
if FileExists(Drive + ':\autorun.inf') = False then Exit;
ini := TIniFile.Create(Drive + ':\autorun.inf');
ico := TIcon.Create;
try
s := ini.ReadString('Autorun', 'ICON', '');
if s = '' then Exit;
if FileExists(s) then ico.LoadFromFile(s);
if FileExists(Drive + ':\' + s) then ico.LoadFromFile(Drive + ':\' + s);
if (FileExists(s) = False) and (FileExists(Drive + ':\' + s) = False) then
begin
for j := (Pos(',', s) + 1) to Length(s) do
begin
p := p + s[j];
end;
i := StrToInt(p);
for j := Length(s) downto (Pos(',', s)) do
Delete(s, j, Length(s));
if FileExists(s) = False then s := Drive + ':\' + s;
ico.Handle := ExtractIcon(hinstance, PChar(s), i);
end;
Result := ico;
finally
ini.Free;
end;
end;
Cevapla