0

If anyone wants to take a crack at this I'd really appreciate it. I'm writing a VB.NET app that will control a commercial backup product. One of the things I need to do is loop through all existing jobs and look at the source drive. I am able to do this in VBScript very simply like this:

Dim SP, BackupJob, volumes
Set SP = CreateObject("ShadowStor.ShadowProtect")
For Each Job In SP.Jobs
    Set BackupJob = SP.Jobs.GetBackupJob(Job.Description)
    BackupJob.GetVolumes volumes
    For Each Volume in volumes
        WScript.Echo volume
    Next
Next
Set SP = Nothing

However nothing I try in VB.NET works. I'm pretty sure it has to do with the fact that the com functions are returning variant data types and arrays (specifically GetVolumes). I have tried using string arrays, object arrays, and even wrapping the return value in a VariantWrapper and I always get errors such as "not implemented" or "the parameter is incorrect." If anyone is bored and wants to write some code I'll gladly give it a shot and report back.

UPDATE:

This is odd. Look at this code:

Dim SP As Object = CreateObject("ShadowStor.ShadowProtect")
Dim gotJob As Object
Dim volumes() As Object

Try
    For Each Job As Object In SP.Jobs
        gotJob = SP.Jobs.GetBackupJob(Job.Description.ToString())
        gotJob.GetVolumes(volumes)

        For Each volume As Object In volumes
            MsgBox(volume.ToString())
        Next

    Next

Catch ex As Exception
    MsgBox(ex.Message)
End Try

This will display the volume from ONE job, then it crashes if there is more than one jobwith the error "invalid callee."

11
  • Since For Each is working in VBScript, I would guess the type is a collection of some sort. Does your COM library contain any collection types? Commented Nov 29, 2011 at 14:07
  • 1
    Kinda pointless to post code that works. Post the code that doesn't work. Commented Nov 29, 2011 at 14:16
  • When you say 'nothing I try in VB>NET works' what do you mean? Do you get an error? At compile time? At runtime? Commented Nov 29, 2011 at 14:21
  • @HansPassant try to think for a second why I might have posted that code. Did you read my question? It should have been obvious to you that I was asking for help in making that same code work in another language. Get it now? Commented Nov 29, 2011 at 20:42
  • @Matt I was pretty clear in stating the 2 errors I receive, and some of the things I have tried. Read the question again, more slowly this time maybe. Commented Nov 29, 2011 at 20:43

2 Answers 2

1

Locate ShadowStor.ShadowProtect in your registry in HKCR. It will have a CLSID which is a GUID. Search for that GUID, also in HKCR. You should find it in the CLSID section. Under that key you should find the actual dll path under InprocServer32.

Now if that component has an embedded TypeLib you should be able to add a reference to it in Visual Studio. (If you have OLE View installed you can inspect the type lib easily as well).

And if you cannot add a reference to the dll, there might be a seperate .tlb file, and you can find that by searching on the GUID present in the TypeLib value.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks. ShadowStor.ShadowProtect is actually the Windows Service that the software installs. I can open the service exe in Object Browser and view all the classes and members but it is not documented at all.
Do you get Intellisense on the objects you create once you reference ShadowStor.ShadowProtect? Hopefully no need to use CreateObject in VB.NET.
Negative. And if I even try to add a reference to the service exe I can't. Visual Studio won't let me. "Please make sure it's a valid assembly or COM component."
So when you said you used "Object Browser", you were not referring to the one within a current Visual Studio? You meant the one within OLE View ("Object Viewer")?
Nope I used object browser and simply clicked the browse button to locate the exe.
0

For anyone interested, the solution was to Dim volumes() As Object inside the loop and then set volumes = Nothing at the end of the loop so that it was re-created each time. If anyone can explain why this is so I would love to understand it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.