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

نسخة كاملة : كيف فتح ملف بإمتداد معين بالنقر عليه مرتين مثل الوورد Word
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم و رحمة الله و بركاته
- كيفية فتح ملف بإمتداد معين بالنقر عليه مرتين مثل الوورد 'Word'
- كيفية الحفاظ على التغييرات المدرجة فيه

أحبكم في الله و السلام عليكم
وعليكم السلام ورحمة الله وبركاته
PHP كود :
uses
  Registry
;

procedure AddFileMenu(FilePrefix, Menue, Command: string);
var
  
reg: TRegistry;
  
typ: string;
begin
  reg 
:= TRegistry.Create;
  
with reg do
  
begin
    RootKey 
:= HKEY_CLASSES_ROOT;
    
OpenKey('.' + FilePrefix, True);
    
typ := ReadString('');
    if 
typ = '' then
    begin
      typ 
:= Fileprefix + 'file';
      
WriteString('', typ);
    
end;
    
CloseKey;
    
OpenKey(typ + '\shell\' + Menue + '\command', True);
    WriteString('', command + ' "%1"');
    CloseKey;
    Free;
  end;
end;

procedure DeleteFileMenu(FilePrefix, Menue: string);
var
  reg: TRegistry;
  typ: string;
begin
  reg := TRegistry.Create;
  with reg do
  begin
    RootKey := HKEY_CLASSES_ROOT;
    OpenKey('
.' + FilePrefix, True);
    typ := ReadString('');
    CloseKey;
    OpenKey(typ + '
\shell', True);
    DeleteKey(Menue);
    CloseKey;
    Free;
  end;
end; 
مثال للاستخدام: لاحقة EXE
PHP كود :
if MessageBox(Handle, PChar('Would you like really add '+Application.Title+' to ShellMenu?'), 
    
'Confirm', MB_YESNO + MB_ICONQUESTION) = IDYES then
    AddFileMenu
('exe', 'Edit with '+Application.Title, Application.ExeName); 
للحذف:
PHP كود :
if MessageBox(Handle, PChar('Do you want to remove '+Application.Title+' from ShellMenu?'), 
    
'Confirm', MB_YESNO + MB_ICONQUESTION) = IDYES then
    DeleteFileMenu
('exe', 'Edit with '+Application.Title); 
هذا في Windows في Linux حيث لا وجود لـ Registry لا أعرف!
أفرد لكل سؤال موضوع
بالتوفيق.