Results 1 to 7 of 7

Thread: Checking if .SDK object exists (and how to handle it if it doesnt) in VB6

  1. #1
    Maximum Bitrate
    Join Date
    Nov 2005
    Posts
    597

    Checking if .SDK object exists (and how to handle it if it doesnt) in VB6

    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

  2. #2
    Confusion Master
    Auto Apps:loading...
    Enforcer's Avatar
    Join Date
    Sep 2003
    Location
    If you go down to the woods today, You're sure of
    Posts
    14,634
    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

  3. #3
    Maximum Bitrate
    Join Date
    Nov 2005
    Posts
    597
    Thanks. I'll try that.

    How can I display the current value of SDK as a text caption?

    My app:
    Code:
    Dim SDK As Object
    ...
    Set SDK = CreateObject("RoadRunner.SDK") 'Roadrunner sdk decl.
    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?

  4. #4
    The Curator
    Auto Apps:loading...
    Blue ZX3's Avatar
    Join Date
    Aug 2004
    Location
    Chicago area,IL
    Posts
    5,079
    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 [v1.0 Released]
    Next in line: RRMedia v2.0

    DFX 5.1.1 Skin
    Appstore Link

    My RideRunner Plugins
    RRMedia
    RRExtended
    DFXVoice

    "There are no bugs - only undocumented features."

  5. #5
    Maximum Bitrate
    Join Date
    Nov 2005
    Posts
    597
    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 work is 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
    Code:
    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
    Is you errortrap code more efficient - if so, Id prefer to get that working .

    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!

  6. #6
    The Curator
    Auto Apps:loading...
    Blue ZX3's Avatar
    Join Date
    Aug 2004
    Location
    Chicago area,IL
    Posts
    5,079
    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 [v1.0 Released]
    Next in line: RRMedia v2.0

    DFX 5.1.1 Skin
    Appstore Link

    My RideRunner Plugins
    RRMedia
    RRExtended
    DFXVoice

    "There are no bugs - only undocumented features."

  7. #7
    Maximum Bitrate
    Join Date
    Nov 2005
    Posts
    597
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •