HTA - how to use a typelib in a DLL ?? 
Author Message
 HTA - how to use a typelib in a DLL ??

Hi,
my goal is to use the "DirectX 8 for Visual Basic Type Library 1.0"
clsID/guid={E1211242-8E94-11D1-8808-00C04FC2C603}

into an HTA, to be able to use DirectInput Method
to capture the Joystick buttons/moves and so on...

I don't know if this typeLib can be used inside HTA ?

I get only a clsID/guid, and there is no ID/name to access the object ...

I would like to use something like:
<object id="myOwnDefinedName"
classid="clsid:E1211242-8E94-11D1-8808-00C04FC2C603">
or
<OBJECT
 classid="clsid:E1211242-8E94-11D1-8808-00C04FC2C603"
 ID=myOwnDefinedName WIDTH=1 HEIGHT=1></OBJECT>

but I don't know if I can define my own name for the typelib ?
and I don't know if I can include this reference in the header of the HTA ?
or even in the body of the HTA ?

I tested the above 2 codes, and get nothing or errors ...
any suggestions, help to capture the joystick inside an HTA,
using DirectInput or anything else will be greatly appreciated :)))

zwetan



Mon, 03 May 2004 03:30:46 GMT  
 HTA - how to use a typelib in a DLL ??
[Please do not mail me a copy of your followup]



Quote:
>my goal is to use the "DirectX 8 for Visual Basic Type Library 1.0"
>clsID/guid={E1211242-8E94-11D1-8808-00C04FC2C603}

>into an HTA, to be able to use DirectInput Method
>to capture the Joystick buttons/moves and so on...

As far as I know, you cannot use this from VBScript, only from VB.  VB
can handle custom interfaces (which it gets from the type library),
but VBScript can only handle dispinterfaces.  If you examine that type
library in OleView, you will see that none of the interfaces are
dispinterfaces.

Quote:
>I don't know if this typeLib can be used inside HTA ?

You can make your own COM object in C++ (or VB) that exposes a
dispinterface to your script and deals with DirectInput.
--
Ask me about my upcoming book on Direct3D from Addison-Wesley!
  Direct3D Book http://www.xmission.com/~legalize/book/
    Don't Support Spammers!  Boycott Fractal Painter 7!
     http://www.xmission.com/~legalize/spammers.html


Mon, 03 May 2004 05:30:41 GMT  
 HTA - how to use a typelib in a DLL ??
Rich, this could be an opportunity to use the "TorrBoy Wrapper", to quote
torrboy himself:

"This component allows you to access the non-default interface(s) of other
components from within scripting languages such as VBScript and JScript. It
can be used from Visual Basic, Windows Scripting Host, and possibly other
ActiveX clients, although it does not work with Active Server Pages at this
time....  "

The "TorrBoy Wrapper" is available for downloading from Clarence
Washington's website:

     http://cwashington.netreach.net/main/default.asp

cheers, jw


Quote:
> [Please do not mail me a copy of your followup]



> >my goal is to use the "DirectX 8 for Visual Basic Type Library 1.0"
> >clsID/guid={E1211242-8E94-11D1-8808-00C04FC2C603}

> >into an HTA, to be able to use DirectInput Method
> >to capture the Joystick buttons/moves and so on...

> As far as I know, you cannot use this from VBScript, only from VB.  VB
> can handle custom interfaces (which it gets from the type library),
> but VBScript can only handle dispinterfaces.  If you examine that type
> library in OleView, you will see that none of the interfaces are
> dispinterfaces.

> >I don't know if this typeLib can be used inside HTA ?

> You can make your own COM object in C++ (or VB) that exposes a
> dispinterface to your script and deals with DirectInput.
> --
> Ask me about my upcoming book on Direct3D from Addison-Wesley!
>   Direct3D Book http://www.xmission.com/~legalize/book/
>     Don't Support Spammers!  Boycott Fractal Painter 7!
>      http://www.xmission.com/~legalize/spammers.html



Mon, 03 May 2004 06:25:02 GMT  
 HTA - how to use a typelib in a DLL ??
[Please do not mail me a copy of your followup]



Quote:
>Rich, this could be an opportunity to use the "TorrBoy Wrapper", to quote
>torrboy himself:

>"This component allows you to access the non-default interface(s) of other
>components from within scripting languages such as VBScript and JScript.
>[...]

This sounded interesting, so I checked it out.  Unfortunately it won't
work in this particular case because the source for the wrapping
operation needs to be an automation object (i.e. a dispinterface).

For example, his test VBScript looks like this:

    Dim oHelper
    Dim oTest
    Dim oWop
    Dim oFoo

    Set oTest = Wscript.CreateObject("InterfaceTest.TestObject")
    Set oHelper = Wscript.CreateObject("Torrboy.Wrapper")
    Set oFoo = oHelper.GetInterface(oTest, "IFoo")
    Set oWop = oHelper.GetInterface(oTest, "IWop")

    oTest.Name = "My Object"
    Wscript.Echo oFoo.FooMethod
    Wscript.Echo oWop.WopMethod

    Set oFoo = Nothing
    Set oWop = Nothing
    Set oTest = Nothing
    Set oHelper = Nothing

In this case, we can't do this because we can't use CreateObject() to
instantiate the DirectInput interface that we would pass to
Torrboy.Wrapper.
--
Ask me about my upcoming book on Direct3D from Addison-Wesley!
  Direct3D Book http://www.xmission.com/~legalize/book/
    Don't Support Spammers!  Boycott Fractal Painter 7!
     http://www.xmission.com/~legalize/spammers.html



Mon, 03 May 2004 06:45:40 GMT  
 HTA - how to use a typelib in a DLL ??

Quote:
> As far as I know, you cannot use this from VBScript, only from VB.  VB
> can handle custom interfaces (which it gets from the type library),
> but VBScript can only handle dispinterfaces.  If you examine that type
> library in OleView, you will see that none of the interfaces are
> dispinterfaces.

ahem on w2000pro OleView does not work, so I found these clsid
using a mix of MSE(from office) and PrimalScript Ole viewer...

Quote:
> You can make your own COM object in C++ (or VB) that exposes a
> dispinterface to your script and deals with DirectInput.

thanks for the answer but here my problems:
I use only script technologies from MS (WSH, HTA, WMI ...),
I understand principal concept of programming (even doing OO script stuff)
but I don't code in C/C++/VB, and I'm not really sure of what is the
difference
between an interface and a dispinterface.

but digging a little more trying to find a way to capture the direct input
I found this reference "DIRECT.Joystick.3" in HKEY_CLASSES_ROOT,
and this guid refer to "dx3j.dll" (Microsoft? DirectX for Java).
And perharps passing by Java it could be possible to use this DLL ?

thanks for your previous answer
cheers
zwetan



Mon, 03 May 2004 07:43:00 GMT  
 HTA - how to use a typelib in a DLL ??
Yes, you can access any method/property of ANY dll via Java.
It is not difficult, but keep in mind that if you wish to deploy it
to others, they must have IE4+ installed. Also, fortunately MS
continues to (and will evidently on an ongoing basis) to provide
their final release of JVM.
To access dlls via Java, you will need to dig a bit into the win32
api, but not much. Better yet, you can create your own class which
provides a good interface to the entire win32 api EVERYTHING
including the kitchen sink.
Unfortunately, there is not a lot of docs at MS on this, so I continue
to provide some workable demos on this via my signed-code stuff
below.
Cheers,
 - Mitch Gallant
   http://home.istar.ca/~neutron/java.html    and
   http://home.iSTAR.ca/~neutron/wsh/
Quote:

> > As far as I know, you cannot use this from VBScript, only from VB.  VB
> > can handle custom interfaces (which it gets from the type library),
> > but VBScript can only handle dispinterfaces.  If you examine that type
> > library in OleView, you will see that none of the interfaces are
> > dispinterfaces.

> ahem on w2000pro OleView does not work, so I found these clsid
> using a mix of MSE(from office) and PrimalScript Ole viewer...

> > You can make your own COM object in C++ (or VB) that exposes a
> > dispinterface to your script and deals with DirectInput.

> thanks for the answer but here my problems:
> I use only script technologies from MS (WSH, HTA, WMI ...),
> I understand principal concept of programming (even doing OO script stuff)
> but I don't code in C/C++/VB, and I'm not really sure of what is the
> difference
> between an interface and a dispinterface.

> but digging a little more trying to find a way to capture the direct input
> I found this reference "DIRECT.Joystick.3" in HKEY_CLASSES_ROOT,
> and this guid refer to "dx3j.dll" (Microsoft? DirectX for Java).
> And perharps passing by Java it could be possible to use this DLL ?

> thanks for your previous answer
> cheers
> zwetan



Mon, 03 May 2004 08:00:29 GMT  
 HTA - how to use a typelib in a DLL ??
[Please do not mail me a copy of your followup]



Quote:
>> As far as I know, you cannot use this from VBScript, only from VB.  VB
>> can handle custom interfaces (which it gets from the type library),
>> but VBScript can only handle dispinterfaces.  If you examine that type
>> library in OleView, you will see that none of the interfaces are
>> dispinterfaces.

>ahem on w2000pro OleView does not work,

Yes, it does.  I just ran it and it worked just fine.

Quote:
>> You can make your own COM object in C++ (or VB) that exposes a
>> dispinterface to your script and deals with DirectInput.

>thanks for the answer but here my problems:
>I use only script technologies from MS (WSH, HTA, WMI ...),
>I understand principal concept of programming (even doing OO script stuff)
>but I don't code in C/C++/VB, and I'm not really sure of what is the
>difference
>between an interface and a dispinterface.

A regular interface (derived from IUnknown) supports early binding as
used in languages like C++ and Visual Basic.

A dispinterface (derived from IDispatch) supports late binding as used
in scripting languages like VBScript and javascript.

For a COM interface to be usable from VBS/JS, it must be a
dispinterface or derived from IDispatch.

For a more detailed explanation, you'll have to read more about COM
and programming in general, I think.
--
Ask me about my upcoming book on Direct3D from Addison-Wesley!
  Direct3D Book http://www.xmission.com/~legalize/book/
    Don't Support Spammers!  Boycott Fractal Painter 7!
     http://www.xmission.com/~legalize/spammers.html



Mon, 03 May 2004 08:15:05 GMT  
 HTA - how to use a typelib in a DLL ??

Quote:
> A dispinterface (derived from IDispatch) supports late binding as used
> in scripting languages like VBScript and javascript.

thanks for the explanation, I get it
zwetan


Mon, 03 May 2004 08:36:24 GMT  
 HTA - how to use a typelib in a DLL ??

Quote:
> Yes, you can access any method/property of ANY dll via Java.
> It is not difficult, but keep in mind that if you wish to deploy it
> to others, they must have IE4+ installed. Also, fortunately MS
> continues to (and will evidently on an ongoing basis) to provide
> their final release of JVM.

thanks a lot :), it's ok the minimum specs are IE5+ cause all is hosted in
an HTA.

Quote:
> To access dlls via Java, you will need to dig a bit into the win32
> api, but not much. Better yet, you can create your own class which
> provides a good interface to the entire win32 api EVERYTHING
> including the kitchen sink.
> Unfortunately, there is not a lot of docs at MS on this, so I continue
> to provide some workable demos on this via my signed-code stuff
> below.

nice ressources, but for what I see inside java/package
I got a zip "DBRB3DV7.zip"
containing "com/ms/directX/DirectInput.class"

is there a way to access it form WSH ?
or is extracting the *.class from the zip and putting aside the WSH file is
enough ?
so I can use: set oDxInput = GetObject("java:DirectInput")

it will be great so this way I need to compil nothing :)
I gonna do some research on that,
thanks for your answer
zwetan



Mon, 03 May 2004 08:34:53 GMT  
 HTA - how to use a typelib in a DLL ??
[----warning" some Java below :-p ]

You  would need to use the fully qualified name:
  set oDxInput = GetObject("java:com.ms.directX.DirectInput")
but that doesn't work, probably because the DirectInput class does
not have a default constructor (or something like that). However,
it is not difficult to write a small wrapper java class (see below) which
can get at all the methods and properties of the DirectInput class,
and then callable from vbs, js or wsh.
Java monikers is not too well documented, of course, so you would
need to be prepared to do some work.

Here is how you would call a wrapper method:
set oMyDirectX= GetObject("java:JDirectInput")   'Instantiate Java object via moniker.
devs = oMyDirectX.JgetNumDevs()

And the wrapper class below  (not completely debugged) just needs to be compiler
(with MS Jvc.exe) and then popped into your C:\winnt\java\classes
and you are ready to roll and call the methods from any vbs or js.
You can of course do exactly the same thing for any MS DirectX classes.

--------  Java class wrapper  MS  com.ms.directX.DirectInput class  ----------------
import com.ms.directX.* ;

public class JDirectInput {
  DirectInput din = new DirectInput() ;

 public void JGetDevCaps(int joyid, JoyCaps pjc) {
    din.getDevCaps(joyid, pjc);
  }
 public String JgetDevCapsOEMVxd(int joyid) {
    return din.getDevCapsOEMVxd(joyid);
  }
 public String JgetDevCapsProductName(int joyid) {
   return din.getDevCapsProductName(joyid);
  }
 public String JgetDevCapsRegKey(int joyid) {
   return din.getDevCapsRegKey(joyid);
  }
 public int JgetNumDevs() {
   return din.getNumDevs();
  }
 public void JgetPos(int joyid, JoyInfo info) {
   din.getPos(joyid, info);
  }

 public static void main(String args[]) {        // standalone test method
   JDirectInput jdin = new JDirectInput() ;
   System.out.println("Number of Devices: " + jdin.JgetNumDevs()) ;
 }

Quote:
}

- Mitch
Quote:

> > Yes, you can access any method/property of ANY dll via Java.
> > It is not difficult, but keep in mind that if you wish to deploy it
> > to others, they must have IE4+ installed. Also, fortunately MS
> > continues to (and will evidently on an ongoing basis) to provide
> > their final release of JVM.

> thanks a lot :), it's ok the minimum specs are IE5+ cause all is hosted in
> an HTA.

> > To access dlls via Java, you will need to dig a bit into the win32
> > api, but not much. Better yet, you can create your own class which
> > provides a good interface to the entire win32 api EVERYTHING
> > including the kitchen sink.
> > Unfortunately, there is not a lot of docs at MS on this, so I continue
> > to provide some workable demos on this via my signed-code stuff
> > below.
> nice ressources, but for what I see inside java/package
> I got a zip "DBRB3DV7.zip"
> containing "com/ms/directX/DirectInput.class"

> is there a way to access it form WSH ?
> or is extracting the *.class from the zip and putting aside the WSH file is
> enough ?
> so I can use: set oDxInput = GetObject("java:DirectInput")

> it will be great so this way I need to compil nothing :)
> I gonna do some research on that,
> thanks for your answer
> zwetan



Mon, 03 May 2004 11:34:01 GMT  
 HTA - how to use a typelib in a DLL ??
thanks a lot for all the info and for the source code :))
zwetan


Mon, 03 May 2004 15:53:58 GMT  
 HTA - how to use a typelib in a DLL ??

While there is no support in an HTA (or client side IE/MSHTA script in general) for access to type library constants and enums, you can still use the include file approach.  A script element with a src attribute pointed to a script file of VBScript Const or JScript global var declarations would give the same net effect.

The problem then is where to get the include files...

1) You could spend a great deal of time and effort with an object browser, a text editor, and copy/paste.

or

2) Use the attached TypeLibExtract.hta (attached as a .txt file for anti-AV purposes).

Here's a copy of the embedded documentation.

<!--
  Filename: TypeLibExtract.hta

    Author: Michael Harris

      Date: 17 October 2001

  Purpose:

  - Extract named constants from a type library and build
    VBScript Const or JScript var declarations.

  - Generated script code can be used to copy/paste as needed
    or to create include files for use in host environments
    that do not yet support type libraries (like HTAs).

  Dependencies:

  - TlbInf32.dll

    For programmatic access to type libraries.

    Distributed with VB 6.0, Office 2000, Windows 2000.

    Note: If all else fails, MarkPryor has version 1.1.81.69
    available at http://home.sprintmail.com/~mpryor
    in connection with his free Lightweight Object Browser.
    See the "Objects in WSH" section of Mark's site.

  - ScriptX

    For use of factory.wait method to emulate VB's DoEvents.
    This is part of the free feature subset that does not
    require a license.

    Available at http://www.meadroid.com/scriptx

  - ADO 2.x or higher

    For use of disconnected recordsets.
-->

--
Michael Harris
Microsoft.MVP.Scripting

Quote:

> Hi,
> my goal is to use the "DirectX 8 for Visual Basic Type Library 1.0"
> clsID/guid={E1211242-8E94-11D1-8808-00C04FC2C603}

> into an HTA, to be able to use DirectInput Method
> to capture the Joystick buttons/moves and so on...

> I don't know if this typeLib can be used inside HTA ?

> I get only a clsID/guid, and there is no ID/name to access the object ...

> I would like to use something like:
> <object id="myOwnDefinedName"
> classid="clsid:E1211242-8E94-11D1-8808-00C04FC2C603">
> or
> <OBJECT
>  classid="clsid:E1211242-8E94-11D1-8808-00C04FC2C603"
>  ID=myOwnDefinedName WIDTH=1 HEIGHT=1></OBJECT>

> but I don't know if I can define my own name for the typelib ?
> and I don't know if I can include this reference in the header of the HTA ?
> or even in the body of the HTA ?

> I tested the above 2 codes, and get nothing or errors ...
> any suggestions, help to capture the joystick inside an HTA,
> using DirectInput or anything else will be greatly appreciated :)))

> zwetan

  TypeLibExtract.txt
6K Download


Thu, 06 May 2004 08:27:29 GMT  
 HTA - how to use a typelib in a DLL ??
[Please do not mail me a copy of your followup]



Quote:
>2) Use the attached TypeLibExtract.hta

Hey, that's nice.  Just the other day I wanted to use the AX control
that wraps the common dialogs and I had to use OleView to extract the
type library information in order to even -find- the constants and
methods that were exposed by this control.  (I couldn't find anything
in MSDN on it, except some stuff buried in the Visual Basic
documentation which wasn't useful enough from VBScript because they
were using the API style way of invoking the common dialogs, not the
AX control.)

Quote:
>  set tli = createobject("tli.tliapplication")
>  set factory = createobject("scriptx.factory")

Where do these objects come from?
--
Ask me about my upcoming book on Direct3D from Addison-Wesley!
  Direct3D Book http://www.xmission.com/~legalize/book/
    Don't Support Spammers!  Boycott Fractal Painter 7!
     http://www.xmission.com/~legalize/spammers.html


Thu, 06 May 2004 22:57:28 GMT  
 HTA - how to use a typelib in a DLL ??

Quote:
> >  set tli = createobject("tli.tliapplication")
> >  set factory = createobject("scriptx.factory")

> Where do these objects come from?

See the comments in the HTA (which I also included in my previous post).  Both components are free and publicly available.

I've also attached a newer version of TypeLibExtract.hta (1.1) that

-- is based on an IFRAME rather than a TEXTAREA to facilitate adding a new SaveAs command.  

-- supports a SaveAs command to save the script code to a TXT file.  

-- adds a header to the extract with type library information and date/time of extract.

-- implements a pseudo status bar since HTAs don't natively support one.

--
Michael Harris
Microsoft.MVP.Scripting

  TypeLibExtract.txt
9K Download


Fri, 07 May 2004 08:33:36 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Using constants defined in a typelib

2. HTA and Dll

3. How can I link to another page using MSHTA (HTA Extension)

4. IE in HTA using ASP

5. Mini File Explorer using HTA

6. Using Winsock in a HTA

7. Using ActiveX or Script to Access Remote Mail Server via HTA Application

8. WScript.Run from HTA using vbscript: File not found

9. Read/write registry key using .asp or .hta

10. Get ScriptFullNameand ScriptName using VBScript in an HTA

11. Using HTA with WSH

12. Can WSH be used in HTA

 

 
Powered by phpBB® Forum Software