delphi4arab منتديات دلفي للعرب

نسخة كاملة : ShellApi كيف افتح امتداد من listbox
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم


ShellApi كيف افتح امتداد من listbox
او مع اي اداة اخرى

كود :
ShellExecute(Handle,'open',***********, nil, nil, SW_SHOWNORMAL) ;
(05-09-2025, 02:29 PM)عَمر كتب : [ -> ]السلام عليكم


ShellApi كيف افتح امتداد من listbox
او مع اي اداة اخرى

كود :
ShellExecute(Handle,'open',***********, nil, nil, SW_SHOWNORMAL) ;

إقتباس :procedure TForm1.ListBox1KeyPress(Sender: TObject; var Key: Char);
var
SelectedFile: string;
FileExt: string;
begin
if (Key = #13) and (ListBox1.ItemIndex >= 0) then // Enter key
begin
SelectedFile := ListBox1.Items[ListBox1.ItemIndex];
FileExt := LowerCase(ExtractFileExt(SelectedFile));

case FileExt of
'.txt', '.log':
ShellExecute(Handle, 'open', 'notepad.exe', PChar(SelectedFile), nil, SW_SHOWNORMAL);
'.pdf':
ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL);
'.exe':
ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL);
else
ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL);
end;
end;
end;

او بالضغط مرتين على الملف المحدد

إقتباس :procedure TForm1.ListBox1DblClick(Sender: TObject);
var
SelectedFile: string;
begin
if ListBox1.ItemIndex >= 0 then
begin
SelectedFile := ListBox1.Items[ListBox1.ItemIndex];
ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL);
end;
end;

أو تحديد موقع الملف

إقتباس :procedure TForm1.Button1Click(Sender: TObject);
var
FilePath: string;
begin
if ListBox1.ItemIndex >= 0 then
begin
FilePath := ListBox1.Items[ListBox1.ItemIndex];
// فتح المجلد وتحديد الملف
ShellExecute(Handle, 'open', 'explorer.exe',
PChar('/select,' + FilePath), nil, SW_SHOWNORMAL);
end;
end;
جميل


كود :
procedure TForm1.ListBox1Click(Sender: TObject); var SelectedFile: string; begin if ListBox1.ItemIndex >= 0 then begin SelectedFile := ListBox1.Items[ListBox1.ItemIndex]; ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL); end;