Code:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long X = FindWindow(vbNullString, "RoadRunner") If X <> 0 Then RoadRunner = True
Hi,
Ive written an app for RR which uses the RR.SDK (COM/API objects).
When I resume from hibernation or if I shutdown RR before shutting down my application, the app crashes. Im pretty sure this is because it cannot find the RR.SDK object. Can anyone tell me how to make my app check for the existance of the object - so my program knows when RR is running and I can write some error handling routines. I need a way to also continuously check. Perhaps every 1-2 seconds.. As RR may be shutdown/hibernated at any time.
That way I can make the app either:
a) force my app to wait till RR (re)loads/reinitialises (eg: resuming from hibernation) before it continues sending commands to RR.
b) save the application's current settings and then exit. This would occur when it still hasnt found the RR object after 5 seconds, so obviously RR has been shutdown. (Previously it would just crash... losing all the setting)
I'm using VB6.
Thanks
Ice
Code:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long X = FindWindow(vbNullString, "RoadRunner") If X <> 0 Then RoadRunner = True
Thanks. I'll try that.
How can I display the current value of SDK as a text caption?
My app:
EDIT: Using FindWindow would I need to check if RR exists before every single send/receive to it? is there any other way (interrupts) rather than polling?Code:Dim SDK As Object ... Set SDK = CreateObject("RoadRunner.SDK") 'Roadrunner sdk decl.
Try something like this:
Replace your SDK.Execute("xxx") and your SDK.GetInfo("xxx") with the below subs
Example: RR_Execute("AUDIO") OR CurrentTrack = RR_GetInfo("TRACKPATH")
Code:Public Sub RR_Execute(sCMD As String) ' This would execute a RR CMD ' and on error, would reset the COM Obj ' then resend the RR CMD SKD.Execute(sCMD) On Error GoTo ErrorTrap ErrorTrap: SDK = Nothing SDK = CreateObject("RoadRunner.SDK") SKD.Execute(sCMD) End Sub Public Sub RR_GetInfo(sCMD As String) ' This would Get Info From RR ' and on error, would reset the COM Obj ' then re-attempt to get the wanted Info Dim Value As String Value = SKD.GetInfo(sCMD) On Error GoTo ErrorTrap RR_GetInfo = Value ErrorTrap: SDK = Nothing SDK = CreateObject("RoadRunner.SDK") Value = SKD.GetInfo(sCMD) RR_GetInfo = Value End Sub
RideRunner...The #1 FE, PERIOD.
Current Project: DFXVoice [Beta Released]
Next in line: RRMedia v2.0
DFX 5.1.1 Skin
Appstore Link
My RideRunner Plugins
RRMedia
RRExtended
DFXVoice
Thanks blue. I tried that code.
Where is says SKD.Execute(sCMD) should it be SDK.Execute(sCMD) instead? I corrected it myself and it works.
Trouble is the On Error doesnt seem to workis it because the SDK.execute function is the one thats actually crashing, so the error is internal to it rather than the RR_execute sub?
I ended up using this
Is you errortrap code more efficient - if so, Id prefer to get that workingCode:Public Sub RR_Execute(sCMD As String) If FindWindow(vbNullString, "RoadRunner") <> 0 Then Set SDK = Nothing Set SDK = CreateObject("RoadRunner.SDK") SDK.Execute (sCMD) Else Wait_for_RR End If End Sub.
The reason I reset SDK is because if RR is closed and then reopened with my app still running, it doesnt know to reset the SDK = "rr.sdk" unless I do it in that subroutine. Unless you can think of another way it can detect that? I feel that getting the SDK errotrap to work would be best!
I'm thinking that what you have there might be best for what you doing, my example above is very close to what I'm currently using in my Media AutoIt script.
RideRunner...The #1 FE, PERIOD.
Current Project: DFXVoice [Beta Released]
Next in line: RRMedia v2.0
DFX 5.1.1 Skin
Appstore Link
My RideRunner Plugins
RRMedia
RRExtended
DFXVoice
I'm pretty sure your method would (should) work.. and it would be better.. but I just cant seem to get it working :s. I dont know if its me.. or if its the SDK.Execute routine.
Thanks for your help so far regardless.
Now I gotta figure out how to make a routine which waits (infinite time) for RR to load, or simply aborts the app if you click OK on the msgbox.
Bookmarks