الاضافات للبرنامج ( اصوات خلفيات ...) - onexite - 09-09-2013
العنوان لا يدل على محتوى الموضوع
استخدمت برنامج الا صلاتي فوجدت انه يقوم بثبيت الاشكال اليا بدون تدخل مني
![[صورة: 72hp.png]](http://img839.imageshack.us/img839/4619/72hp.png)
وبعد تتبع الرجستري وجدت بعض المفاتيح بالاضافة الى مكون لفك الضغط
الطريقة كمايلي
المتطلبات دلفي xe2 او اكثر لهذا الشرح
uses Vcl.Dialogs,zip
PHP كود : procedure MyzipExtract(FileName,myPath: string); var ZipFile : TZipFile; begin ZipFile := TZipFile.Create; if not ZipFile.IsValid(FileName) then begin ShowMessage('الملف غير صالح'); Exit; end; try ZipFile.ExtractZipFile(FileName,myPath); finally ZipFile.Free; end; end;
اضافة هذه الوحدة للمشروع
PHP كود : unit RegisterFile;
interface uses Registry, ShlObj, SysUtils, Windows;
procedure RegisterFileType(cMyExt, cMyFileType, cMyDescription, ExeName: string; IcoIndex: integer; DoUpdate: boolean = false);
implementation
procedure RegisterFileType(cMyExt, cMyFileType, cMyDescription, ExeName: string; IcoIndex: integer; DoUpdate: boolean = false); var Reg: TRegistry; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_CLASSES_ROOT; Reg.OpenKey(cMyExt, True); // Write my file type to it. // This adds HKEY_CLASSES_ROOT\.abc\(Default) = 'Project1.FileType' Reg.WriteString('', cMyFileType); Reg.CloseKey; // Now create an association for that file type Reg.OpenKey(cMyFileType, True); // This adds HKEY_CLASSES_ROOT\Project1.FileType\(Default) // = 'Project1 File' // This is what you see in the file type description for // the a file's properties. Reg.WriteString('', cMyDescription); Reg.CloseKey; // Now write the default icon for my file type // This adds HKEY_CLASSES_ROOT\Project1.FileType\DefaultIcon // \(Default) = 'Application Dir\Project1.exe,0' Reg.OpenKey(cMyFileType + '\DefaultIcon', True); Reg.WriteString('', ExeName + ',' + IntToStr(IcoIndex)); Reg.CloseKey; // Now write the open action in explorer Reg.OpenKey(cMyFileType + '\Shell\Open', True); Reg.WriteString('', '&Open'); Reg.CloseKey; // Write what application to open it with // This adds HKEY_CLASSES_ROOT\Project1.FileType\Shell\Open\Command // (Default) = '"Application Dir\Project1.exe" "%1"' // Your application must scan the command line parameters // to see what file was passed to it. Reg.OpenKey(cMyFileType + '\Shell\Open\Command', True); Reg.WriteString('', '"' + ExeName + '" "%1"'); Reg.CloseKey; // Finally, we want the Windows Explorer to realize we added // our file type by using the SHChangeNotify API. if DoUpdate then SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil); finally Reg.Free; end; end;
end.
الان الاستغلال في زر تسجيل الاشكال والخلفيات والاصوات
PHP كود : RegisterFileType('.salaty_style', '.salaty_style', 'SalatyStyle', ParamStr(0), 1,True); RegisterFileType('.salaty_wall', '.salaty_wall', 'SalatyWallpaper', ParamStr(0), 2,True); RegisterFileType('.salaty_sound', '.salaty_sound', 'SalatySound', ParamStr(0), 3,True);
الان ستجد الملفات تغير شكلها
PHP كود : program Project1;
uses Vcl.Forms,Vcl.Dialogs, Functions,System.SysUtils, Main in 'Main.pas' {Form1};
{$R *.res}
begin if pos('.salaty_style',ParamStr(1))>0 then if MessageDlg('هل تريد اضافة هذا الشكل الى البرنامج',mtConfirmation, mbOKCancel, 0)=1 then MyZipExtract(ParamStr(1),ExtractFilePath(ParamStr(0))+'styles') ;
الكود السابق ذكره قبل Application.Initialize;
لم ينتهي الموضوع بعد
اذن لديك اشكال ضعهم في ملف مضغوط من نوع zip
اعد تسميته الى test.salaty_style
ستجد ان الايقونة تغيرت قم بفتحه ستظهر هذه الرسالة
![[صورة: al8r.png]](http://img844.imageshack.us/img844/6650/al8r.png)
وافق عليه وستجد ان الملفات تم فك الضغط عليهم في مسار البرنامج + styles
انتهى الموضوع
الاضافات للبرنامج ( اصوات خلفيات ...) - onexite - 09-09-2013
عليكم باضافة هذه الدالة التي تتحق من وجود الملف
PHP كود : procedure notDexist(path:string); begin if not DirectoryExists(path) then MkDir(path); end;
والاستخدام
PHP كود : if pos('.salaty_style',ParamStr(1))>0 then if MessageDlg('هل تريد اضافة هذا الشكل الى البرنامج',mtConfirmation, mbOKCancel, 0)=1 then begin notDexist(ExtractFilePath(ParamStr(0))+'styles'); MyZipExtract(ParamStr(1),ExtractFilePath(ParamStr(0))+'styles') ; end;
if pos('.salaty_wall',ParamStr(1))>0 then if MessageDlg('هل تريد اضافة هذه الخلفيات الى البرنامج',mtConfirmation, mbOKCancel, 0)=1 then begin notDexist(ExtractFilePath(ParamStr(0))+'backgrounds'); MyZipExtract(ParamStr(1),ExtractFilePath(ParamStr(0))+'backgrounds') ; end;
if pos('.salaty_sound',ParamStr(1))>0 then if MessageDlg('هل تريد اضافة هذه الاصوات الى البرنامج',mtConfirmation, mbOKCancel, 0)=1 then begin notDexist(ExtractFilePath(ParamStr(0))+'sounds'); MyZipExtract(ParamStr(1),ExtractFilePath(ParamStr(0))+'sounds') ; end;
والنتيجة النهائية
الاضافات للبرنامج ( اصوات خلفيات ...) - onexite - 15-03-2014
حسب الدالة السابق ذكرها فان الايقونات يتم تعريفهم من خلال الملف التطبيقي
procedure RegisterFileType(cMyExt, cMyFileType, cMyDescription, ExeName: string; IcoIndex: integer; DoUpdate: boolean = false);
اذن انشا ملف جديد name.rc وضع فيه مايلي
1 ICON 1.ico
2 ICON 2.ico
3 ICON 3.ico
واستخدم هذا الامر brcc32 name.rc
وستحصل
![[صورة: i9th.jpg]](http://img36.imageshack.us/img36/221/i9th.jpg)
اضف هذا السطر لبرنامجك
{$R *.dfm}
{$R name.res}
الاضافات للبرنامج ( اصوات خلفيات ...) - zouzou05 - 06-04-2014
شكرا لك أخي وجزاك الله خيرا ...
افدتنا كثيرا بدروسك القيمة خصوصا التعامل مع النت بالدلفي لم أجد اي أمثلة عربية في هذا المجال سوى أمثلتك
شكرا لك
|