我在powerbuilder 9.0中declare了全局函数mciSendString
然后在一个窗口对象中添加了一个按钮,在按钮的clicked事件中写如下的东西。
编译通过然后运行点击该按钮时报 bad runtime function reference at line 5……string ls_command,ls_buffer,ls_filename
ls_filename="111.avi"
ls_buffer=fill(Char(0),255)
ls_command="open" + ls_filename + "type avivideo alias avi"
mciSendString(ls_command,ls_buffer,255,handle(parent))
ls_command="play mp3"
mciSendString(ls_command,ls_buffer,255,handle(parent))请高手们帮忙解决下,多谢了!
还有我想问在powerbuilder中能不能调用createprocess函数?

解决方案 »

  1.   

    1.instance variables
    string wavfile
    boolean b_wav=false,b_avi=false,b_first = true
    string is_file_name
    boolean b_test = false2.local external functions
    Function boolean sndPlaySoundA(string wavfile, uint flag) Library "WINMM.DLL"
    Function uint waveOutGetNumDevs() Library "WINMM.DLL"
    FUNCTION long mciSendStringA(string lpstrCommand,ref string lpstrReturnString,int wReturnLength,uint hwndCallback) LIBRARY "winmm.dll"
    FUNCTION boolean mciGetErrorStringA(long dwError,ref string lpstrBuffer,int wLength) LIBRARY "winmm.dll"3.选择文件的按钮:
    int value
    string file
    uint lui_NumDevs
    string file2
    setnull(file2)lui_NumDevs = waveOutGetNumDevs()cb_wavstop.enabled = false
    IF lui_NumDevs > 0 THEN
    sndPlaySoundA(file2,0)
    value = GetFileOpenName("选择文件", wavfile, file,"wav","WAV文件(*.wav),*.wav") if value = 1 then 
    st_wav.text = wavfile
    cb_wavplay.enabled = true
    cb_wavrepeat.enabled = true
    st_wavsta.text = "SELECTED..."
    else
    cb_wavplay.enabled = false
    cb_wavrepeat.enabled = false
    st_wavsta.text = "FAIL..."
    end if
    else
    cb_wavplay.enabled = false
    cb_wavrepeat.enabled = false
    this.enabled = false
    messagebox("设备错误","无法正常播放WAV文件!",StopSign!)
    end if4.播放
    uint   flagflag = 1 
    sndPlaySoundA(wavfile,flag)cb_wavstop.enabled = true
    st_wavsta.text = "PLAYING..."
    5.重复
    uint   flag
    flag = 9 
    sndPlaySoundA(wavfile,flag)
    cb_wavstop.enabled = true
    st_wavsta.text = "REPEATING..."6.停止
    string file
    setnull(file)sndPlaySoundA(file,0)cb_wavplay.enabled = true
    cb_wavrepeat.enabled = true
    this.enabled = falsest_wavsta.text = "STOP..."