The MP3car.com Store  

Welcome to the MP3Car.com forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   MP3Car.com > Mp3Car Technical > Software & Software Development > Front Ends > Road Runner

Reply
 
Thread Tools Search this Thread Display Modes
Old 03-28-2008, 11:47 PM   #1
Maximum Bitrate
Iceman_jkh's CarPC Specs
 
Join Date: Nov 2005
Posts: 559
My Photos: (1)
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
Iceman_jkh is offline   Reply With Quote
Sponsored Links
Old 03-29-2008, 12:28 AM   #2
Confusion Master
Enforcer's CarPC Specs
 
Enforcer's Avatar
 
Join Date: Sep 2003
Location: If you go down to the woods today, You're sure of
Vehicle: 1997 BMW E36 328I
Posts: 9,899
My Photos: (1)
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

Enforcer is offline   Reply With Quote
Old 03-29-2008, 01:00 AM   #3
Maximum Bitrate
Iceman_jkh's CarPC Specs
 
Join Date: Nov 2005
Posts: 559
My Photos: (1)
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?

Last edited by Iceman_jkh; 03-29-2008 at 01:03 AM.
Iceman_jkh is offline   Reply With Quote
Old 03-29-2008, 04:26 AM   #4
Raw Wave
Blue ZX3's CarPC Specs
 
Blue ZX3's Avatar
 
Join Date: Aug 2004
Location: Chicago area,IL
Vehicle: 01 Ford ZX3
Posts: 2,148
My Photos: (16)
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

Blue ZX3 is offline   Reply With Quote
Old 03-29-2008, 09:06 AM   #5
Maximum Bitrate
Iceman_jkh's CarPC Specs
 
Join Date: Nov 2005
Posts: 559
My Photos: (1)
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!

Last edited by Iceman_jkh; 03-29-2008 at 09:22 AM.
Iceman_jkh is offline   Reply With Quote
Old 03-29-2008, 10:29 AM   #6
Raw Wave
Blue ZX3's CarPC Specs
 
Blue ZX3's Avatar
 
Join Date: Aug 2004
Location: Chicago area,IL
Vehicle: 01 Ford ZX3
Posts: 2,148
My Photos: (16)
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.
Blue ZX3 is offline   Reply With Quote
Old 03-29-2008, 10:48 AM   #7
Maximum Bitrate
Iceman_jkh's CarPC Specs
 
Join Date: Nov 2005
Posts: 559
My Photos: (1)
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.
Iceman_jkh is offline   Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT -5. The time now is 10:54 PM.


Sponsored Links
The MP3car.com Store

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 1999 - 2008 Mp3Car.com Inc.
Ad Management by RedTyger
Message Board Statistics