منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
لاصدار صوت الصافرة من الجهاز بستخدام العديد من دوال APIs - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : الأقسام التعليمية - المنتدى القديم (http://vb4arb.com/vb/forumdisplay.php?fid=90)
+--- قسم : مكتبة أكواد المنتدى (http://vb4arb.com/vb/forumdisplay.php?fid=111)
+---- قسم : مكتبة أكواد .net (http://vb4arb.com/vb/forumdisplay.php?fid=117)
+---- الموضوع : لاصدار صوت الصافرة من الجهاز بستخدام العديد من دوال APIs (/showthread.php?tid=6162)



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

كاتب الموضوع : 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]