您好,欢迎访问三七文档
SoundoutputbyCscriptinWinCCThisentryisavailableinthefollowinglanguages:EntryID:748844Date:06/11/2002QUESTION:HowcanIoutputasoundviaCscriptinWinCC?ANSWER:Attachedisasmallexample.ThisCactionisbehindabutton,sothatyoujustclicktothebuttontoproduceasound.Caction:#includeapdefap.hvoidOnClick(char*lpszPictureName,char*lpszObjectName,char*lpszPropertyName,UINTnFlags,intx,inty){#pragmacode(Winmm.dll)VOIDWINAPIPlaySoundA(char*pszSound,char*hmode,DWORDdwflag);#pragmacode()PlaySoundA(C:\\Winnt.400\\Media\\tada.wav,NULL,1);}Requirementforthisfunctionisasoundcard.ExplanationofthePlaySoundAfunction:1.Parameterchar*pszSound:Hereyouspecifythecompletepathtowhereyoursoundfile(*.wavfile)islocated.2.Parameterchar*hmode:Hereyoualwaysspecify0.3.ParameterDWORDdwflag.SND_SYNC=0x0000:soundfileisplayedonceandthescriptwaitsuntilithasbeenplayedtotheendSND_ASYNC=0x0001:soundfileisplayedonce,thescriptisprocessedinparallelSND_NODEFAULT=0x0002:ifthesoundfileisnotfound,thennodefaultvalueisplayed,butnothingatall.SND_LOOP=0x0008:repeatsthesoundfileuntilthenextPlaySoundAcallcomes(onlypossiblewith0x0001)=alwaysspecify0x0009.Theseparameterscanalsobecombinedbutbit-by-bitOrs(e.g.:SND_ASYNC|SND_LOOP)Note:Ifyouwanttousethebeepofthecomputer'sinternalloudspeakerinsteadofasoundfile,thenimplementthefollowingscript:Sincetheinternalloudspeakerisaddressed,thereisnoneedforasoundcard.#includeapdefap.hvoidOnClick(char*lpszPictureName,char*lpszObjectName,char*lpszPropertyName,UINTnFlags,intx,inty){#pragmacode(Kernel32.dll)BOOLBeep(DWORDdwFreq,DWORDdwDuration);//dwFreqdefinesthefrequencyofthebeepinhertz//dwDurationspecifiesthedurationofthebeepinmilliseconds#pragmacode()Beep(1000,100);//Example:frequency1000hertz,100milliseconds}Giveusyourfeedback...Questions/suggestionsrethisEntryID
本文标题:span
链接地址:https://www.777doc.com/doc-5332913 .html