![]() |
|
كيف أعرف اسم القرص - نسخة قابلة للطباعة +- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum) +-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3) +--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15) +--- الموضوع : كيف أعرف اسم القرص (/showthread.php?tid=2294) |
كيف أعرف اسم القرص - FPS - 12-08-2010 السلام عليكم جزاكم الله خيراً على مجاهديكم... كيف أعرف اسم قرص محدد مثلا القرص C:\ اسمه local disk كيف أحصل على هذا الإسم؟ كيف أعرف اسم القرص - kachwahed - 12-08-2010 وعليكم السلام ورحمة الله للاستعلام عن معلومات قطاع من القرص نستخدم التابع GetVolumeInformation عبارة Local Disk يعبر عنها Windows عندما لا يتم تسمية القرص فإذا رأيت اسمه Local Disk يعني أن اسمه في الحقيقة هو '' بناء على ذلك يمكن أن نكتب: كود : function GetVolumeName(DriveLetter: Char): string;
var
dummy: DWORD;
buffer: array[0..MAX_PATH] of Char;
oldmode: LongInt;
begin
oldmode := SetErrorMode(SEM_FAILCRITICALERRORS);
try
GetVolumeInformation(PChar(DriveLetter + ':\'),
buffer,
SizeOf(buffer),
nil,
dummy,
dummy,
nil,
0);
if buffer = '' then Result := 'Local Disk' else
Result := StrPas(buffer);
finally
SetErrorMode(oldmode);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := GetVolumeName('c');
end;بالتوفيق. كيف أعرف اسم القرص - abdelmalek - 13-08-2010 اخي kachwahed : لي سؤال : اين هم من ادا اجاب عن شيئ فهما (شرح) وادا صمت توعدا اخي انت تكتب تابع GetVolumeName ولم تشرح تابع SetErrorMode والله عجبا . كما تلاحظ ان FPS هو عضو مبتدأ ( طبعا من طريقة طرح السؤال) اسف واعتدر عن كلامي فانا ( متكلم بسم المبتدئين ) في امان الله بالتوفيق للجميع كيف أعرف اسم القرص - kachwahed - 13-08-2010 الأخ abdelmalek جيد أنك تحدثت بكل بصراحة ![]() 1- إعلم أن الذي يكتب كود ليس بالضرورة أن يفهم كل ما جاء فيه! كما قد يظن بعض المبتدئين... ولا يعني طبعا أنه يحفظه أن ظهر قلب ! يعني أنا أيضا لا أعرف ما معنى SetErrorMode وإنما نسختها كما هي ! لكن... لننظر ولنفتح من دلفي: Help -> Windows SDK ونبحث عن التابع SetErrorMode يمكنك البحث في MSDN أيضا: كود : http://msdn.microsoft.com/en-us/library/ms680621%28VS.85%29.aspxكود : The [color=Blue]SetErrorMode [/color]function controls how the operating system handles several types of serious errors. You can specify that the operating system will handle these errors or that the application will receive and handle them.إقتباس :الدالة SetErrorMode تتحكم في نظام التشغيل يتعامل مع عدة أنواع من أخطاء خطيرة. يمكنك تحديد أن نظام التشغيل ومعالجة هذه الأخطاء أو أن الطلب سوف تلقي والتعامل معها. تعريف التابع: كود : UINT SetErrorMode(
UINT uMode // set of bit flags that specify error-handling properties
);شرح المعلمة: كود : Parameters
uMode
A set of bit flags that specify system error-handling properties. The following error mode bit flag constants are defined; you can set any combination of them:القيمة الممكنة وشرحها: كود : [color=Blue]SEM_FAILCRITICALERRORS[/color] If this flag is set, the operating system does not display the critical-error-handler message box when such an error occurs. Instead, the operating system sends the error to the calling process.
[color=Blue]SEM_NOALIGNMENTFAULTEXCEPT[/color] If this flag is set, the operating system automatically fixes memory alignment faults and makes them invisible to the application. It does this for the calling process and any descendant processes. This flag always affects MIPS processors. It has no effect on x86 processors.If the registry value \CurrentControlSet\Control\Session Manager:EnableAlignmentFaultExceptions is set to REG_DWORD 0x0, this key has no effect on ALPHA processors. That is the system default. If the registry key is set to REG_DWORD 0x1, the [color=Blue]SEM_NOALIGNMENTFAULTEXCEPT[/color] flag does affect ALPHA processors.
[color=Blue]SEM_NOGPFAULTERRORBOX[/color] If this flag is set, the operating system does not display the general-protection-fault message box when such an error occurs. This flag should only be set by debugging applications that handle general protection (GP) faults themselves via an appropriate exception handler.
[color=Blue]SEM_NOOPENFILEERRORBOX[/color] If this flag is set, the operating system does not display a message box when it fails to find a a file. Instead, the error is returned to the calling process.القليل من التجارب في دلفي (أكتب الدالة وغير قيمة المعلمة في كل مرة وجرب التنفيذ...) الآن صرنا نعرف عمل هذا التابع. أرأيت؟ كل شيء موجود بالبحث ![]() إقتباس :اخي انت تكتب تابع GetVolumeName ولم تشرح تابع SetErrorMode والله عجبا .2- انتبه فقد تجعل البعض يرفض الإجابة أصلا بسبب مثل هذه الردود، أو بسبب أنه سينجر إلى المزيد من الأسئلة! إقتباس :كما تلاحظ ان FPS هو عضو مبتدأ ( طبعا من طريقة طرح السؤال)3- طبعا لا يمكن أن نعرف المبتدئ من غيره والسؤال هو الذي يفرض نوع الإجابة. يعني إذا كان السؤال عن شيء صعب (في نظر السائل) فلا تنتظر أن تكون الإجابة بسيطة! شكرا أخي abdelmalek على توضيحك ![]() بالتوفيق. كيف أعرف اسم القرص - abdelmalek - 13-08-2010 هههههههه والله اعجبتني بشرحك هدا اخي kachwahed لقد زدتني اعجابا بك جزاك الله خيرا سلامي وحبي لك اخي في امان الله |