Date of registration: Mar 16th 2009
Location: Perth, WA, Australia
Occupation: Software/Test Engineer
Hobbies: be a husband and a dad, play ukulele, sing
How do I cast oShell.getObject() to Dispatch type? Or is there something I'm missing?
Quoted
Hallo Bruce,
Thank You for the Your article. I've tested the program (Windows 7, Jacobo 1.5.2, path to jacob.jar added to classpath, jacob.dll in c:\widows\system32) and got the the error
"Converting 'java/lang/Object' to 'com/jacob/com/Dispatch' not possible!"
in line Set dShell = oShell.getObject().
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Public Sub main(ByJava args() As String)
Dim myArgs() As String
myArgs = args
Dim oShell As ActiveXComponent
'ActiveXComponent is exported by JACOB and referenced in the IDE
'(yes, there’s an IDE, and it’s pretty good too)
Set oShell = New ActiveXComponent("WScript.Network")
Dim a As String
Dim b As String
Dim c As String
Dim dShell As Dispatch
'Dispatch also part of JACOB. Nice that it uses the standard jargon
Set dShell = oShell.getObject()
a = Dispatch.call(dShell,"UserDomain")
b = Dispatch.call(dShell,"ComputerName")
c = Dispatch.call(dShell,"UserName")
MsgBox (a & ", " & b & ", " & c)
comthread.Release()
End Sub
|
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
|
|
Jabaco Source |
1 2 3 4 5 |
dShell = Cast(oShell.getObject(), Dispatch)
or
dShell = Cast(oShell.getObject(), com#jacob#com#Dispatch)
|
Date of registration: Mar 16th 2009
Location: Perth, WA, Australia
Occupation: Software/Test Engineer
Hobbies: be a husband and a dad, play ukulele, sing
Quoted
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77d66545, pid=5976, tid=6140
#
# JRE version: 6.0_17-b04
# Java VM: Java HotSpot(TM) Client VM (14.3-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x36545]
#
# An error report file with more information is saved as:
# J:\jacob\hs_err_pid5976.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Date of registration: Mar 16th 2009
Location: Perth, WA, Australia
Occupation: Software/Test Engineer
Hobbies: be a husband and a dad, play ukulele, sing