Sign in to follow this  
Followers 0
pdaughe

Can a Developer please explain....

3 posts in this topic

Below is the example from the _SoundOpen UDF. If you run it, and you receive the message box "Success" message, change the _SoundOpen argument to a non-sound, but existing, file name.

The problem I experience here is not really with this UDF -- it's with the DLL call. On my system if that DLL is executed, control is never returned to the script -- it just goes away with no indication that anything went wrong. I was actually attempting to trace down another problem (may or may not be related) when I discovered this one.

I would appreciate someone else running this and letting me know if it's something unqiue to my system.

Thanks very much.

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
    MsgBox(0, "Error", "The file does not exist")
    Exit
ElseIf @error = 3 Then
    MsgBox(0, "Error", "The alias was invalid")
    Exit
ElseIf @extended <> 0 Then
    $extended = @extended ;assign because @extended will be set after DllCall
    $errorstring = DllCall("winmm.dll","int","mciGetErrorStringA","str",$extended,"str","","int",65534,"hwnd",0)
    MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & $errorstring[2] & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox(0, "Success", "The file opened successfully")
EndIf
_SoundPlay($sound, 1)

_SoundClose($sound)

MsgBox (0, "What Happened", "Never executed")

Share this post


Link to post
Share on other sites



Ah, I just thought of something to try. If I run the example from ScITE, it behaves as I described. However, if I compile the example and run the exe, I get an AutoIt Error message box indicating that the stack has become corrupt.

"Stack corruption typically occurs when either the wrong calling convention is used or when the function is called with the wrong number of arguments."

Perhaps the problem IS with the UDF -- DLL call.

One always learns. I compiled the script I was having the problem with and ran it and -- finally -- I get the AutoIt Error message! I wonder if the problem lies in the DLL calling convention being used....

Back to work.

Paul

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try modifying the Dll Call accordingly:

$errorstring = DllCall("winmm.dll","int:cdecl","mciGetErrorStringA","str",$extended,"str","","int",65534,"hwnd",0)

- The Kandie Man ;-)

EDIT: Hmm, interesting, after trying this myself I have had no luck. Seems to be an internal autoit problem. The call stack always seems to become corrupt.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0