تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
لاصدار صوت الصافرة من الجهاز بستخدام العديد من دوال APIs
#1
كاتب الموضوع : AhmedEssawy

لاصدار صوت الصافرة من الجهاز بستخدام العديد من دوال APIs

اولا قم يتعريف الدوال (dll)التي سوف تعتمد عليها كالاتي :


كود :
[align=left]
[color=green][FONT=Courier New]// Declare version [/FONT][/color]

[FONT=Courier New][[color=teal]DllImport[/color]([color=maroon]"kernel32.dll"[/color], EntryPoint=[color=maroon]"Beep"[/color])][/FONT]
[FONT=Courier New][color=blue]public[/color] [color=blue]static[/color] [color=blue]extern[/color] [color=blue]int[/color] DeclareBeep([color=blue]int[/color] dwFreq, [color=blue]int[/color] dwDuration);[/FONT]

[FONT=Courier New][color=green]// DLLImport version[/color][/FONT]
[FONT=Courier New][[color=teal]DllImport[/color]([color=maroon]"kernel32.dll"[/color], EntryPoint=[color=maroon]"Beep"[/color])][/FONT]
[FONT=Courier New][color=blue]public[/color] [color=blue]static[/color] [color=blue]extern[/color] [color=blue]int[/color] DLLImportBeep([color=blue]int[/color] dwFreq, [color=blue]int[/color] dwDuration);[/FONT]

[FONT=Courier New][color=green]// Specifying Unicode[/color][/FONT]
[FONT=Courier New][[color=teal]DllImport[/color]( [color=maroon]"Kernel32.dll"[/color], EntryPoint=[color=maroon]"Beep"[/color], CharSet=[color=teal]CharSet[/color].Unicode )][/FONT]
[FONT=Courier New][color=blue]public[/color] [color=blue]static[/color] [color=blue]extern[/color] [color=blue]int[/color] UnicodeBeep([color=blue]int[/color] dwFreq, [color=blue]int[/color] dwDuration);[/FONT]

[FONT=Courier New][color=green]// Specifying Ansi[/color][/FONT]
[FONT=Courier New][[color=teal]DllImport[/color]( [color=maroon]"Kernel32.dll"[/color], EntryPoint=[color=maroon]"Beep"[/color], CharSet=[color=teal]CharSet[/color].Ansi )][/FONT]
[FONT=Courier New][color=blue]public[/color] [color=blue]static[/color] [color=blue]extern[/color] [color=blue]int[/color] ANSIBeep([color=blue]int[/color] dwFreq, [color=blue]int[/color] dwDuration);[/FONT]

[FONT=Courier New][color=green]// Specifying Auto[/color][/FONT]
[FONT=Courier New][[color=teal]DllImport[/color]( [color=maroon]"Kernel32.dll"[/color], EntryPoint=[color=maroon]"Beep"[/color], CharSet=[color=teal]CharSet[/color].Auto )][/FONT]
[FONT=Courier New][color=blue]public[/color] [color=blue]static[/color] [color=blue]extern[/color] [color=blue]int[/color] AutoBeep([color=blue]int[/color] dwFreq, [color=blue]int[/color] dwDuration);[/FONT]

[FONT=Courier New][color=green]// Using Exact Spelling[/color][/FONT]
[FONT=Courier New][color=green]// Default is FALSE[/color][/FONT]
[FONT=Courier New][color=green]// if FALSE an A is appended under ANSI and a W under Unicode so MessageBox becomes [/color][/FONT]
[FONT=Courier New][color=green]// MessageBoxW[/color][/FONT]

[FONT=Courier New][[color=teal]DllImport[/color]([color=maroon]"kernel32.dll"[/color], EntryPoint=[color=maroon]"Beep"[/color], ExactSpelling=[color=blue]true[/color], CharSet=[color=teal]CharSet[/color].Ansi)][/FONT]
[FONT=Courier New][color=blue]public[/color] [color=blue]static[/color] [color=blue]extern[/color] [color=blue]int[/color] ExactSpellingBeep([color=blue]int[/color] dwFreq, [color=blue]int[/color] dwDuration);[/FONT]
[/align]

الان نادي احدي هذه الدوال

كود :
[color=blue][FONT=Courier New]private[/FONT][/color][FONT=Courier New] [color=blue]void[/color] doSound(int x) [/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New][color=blue]if[/color] (x == 1 )[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New][color=teal]CallingVariations[/color].DeclareBeep(1000, 1000);[/FONT]
[FONT=Courier New]} [/FONT]
[FONT=Courier New][color=blue]else[/color] [color=blue]if[/color] (x == 2) [/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New][color=teal]CallingVariations[/color].DLLImportBeep(1000, 1000);[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New][color=blue]else[/color] [color=blue]if[/color] (x == 3) [/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New][color=teal]CallingVariations[/color].ANSIBeep(1000, 1000);[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New][color=blue]else[/color] [color=blue]if[/color] (x == 4)[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New][color=teal]CallingVariations[/color].UnicodeBeep(1000, 1000);[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New][color=blue]else[/color] [color=blue]if[/color] (x == 5)[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New][color=teal]CallingVariations[/color].AutoBeep(1000, 1000);[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New]}[/FONT]

}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  استخدام دوال مكتبة من ملف DLL بدون إضافته كمرجع Reference @@أبورائد@@ 7 7,835 18-11-21, 05:30 AM
آخر رد: kaled2025
  عمل Copy-Paste من صوره على الجهاز الى البرنامج RaggiTech 0 2,478 17-10-12, 08:56 PM
آخر رد: RaggiTech
  معرفة العنوان الفيزيائي لكروت الشبكة المثبة على الجهاز RaggiTech 0 2,351 17-10-12, 06:47 PM
آخر رد: RaggiTech
  لمعرفة الطابعات المثبة على الجهاز RaggiTech 0 1,879 17-10-12, 06:15 PM
آخر رد: RaggiTech
  كيفية عمل Restore Point مع جميع خصائصه باستعمال دوال ال API RaggiTech 0 2,063 17-10-12, 06:00 PM
آخر رد: RaggiTech
  لمعرفه نوع القرص المتصل بالجهاز بالاعتماد علي APIs RaggiTech 0 1,694 17-10-12, 05:41 PM
آخر رد: RaggiTech
  لمعرفه اسم الجهاز بال C# و VB.net RaggiTech 0 2,767 17-10-12, 05:39 PM
آخر رد: RaggiTech
  لمعرفه Ip الجهاز RaggiTech 0 2,022 17-10-12, 05:39 PM
آخر رد: RaggiTech
  لمعرفة هل الجهاز متصل بانترنت VB.net 2005 RaggiTech 0 1,881 17-10-12, 05:39 PM
آخر رد: RaggiTech
  للحصول علي مكان ملف النظام(SystemFolder) علي الجهاز RaggiTech 0 1,639 17-10-12, 05:36 PM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم