WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Constants

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List Object Constants


Question:

I am just beginning to play with OLE and I was wondering if there is a way to reference the constants of an object. I am looking to automate some of our Citrix Metaframe XP server processes and was looking at examples and it appears that they reference the constants at the beginning of the scripts.

If there is not a way to reference the object is there a way to list the constants?

VB Syntax
reference object="MetaFrameCOM.MetaFrameFarm"/

Perl Syntax
use Win32::OLE::Const('Citrix MetaFrame COM Library');

Answer:

Don't think there is a direct way of including constants into WB.

However here is some code to enumerate a particular TLB/DLL for OLE:

The TLBINF32.DLL should be tucked away in your windows\system. You can use it to examine any .tlb,olb,dll,or ocx that is registered as a type lib on your system. Once you know that, the attached script will enumerate the constants to a text file. Yes, you can also do methods and properties but that can be a pain.

You might also want to check the Tech Database for some neat stuff I did with Detlev in 2002 - to obtain a list of all typelibs, or valid OLE ProgId's on a system : http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/Constants+Updated~OLE~Constants~from~Stan.txt

P.S. the file may not come with XP, or is called TypeLib.Dll

TYPELIB.WBT

; Winbatch - use the OLE Extender to examine TypeLibs
; This example enumerates a certain collection type in
; the typelib, I chose VSFLEX7.OCX as an Example
; Stan Littlefield - November 29, 2002

; I have attached two files with this script
; tlbinfo32.dll - place in \windows or \system dir
;               - then register it, it is an ActiveX control
;               - that acts like the Object Browser
;
; tlbinfo32.chm - help file for the object

; this is what I have gleaned so far
; NOTE: TypeLib Collections are 1-based, or For i=1 To collection.count
; NOTE: ObjectCollectionOpen() caused a GPF on my system

ErrIni         = StrCat( DirWindows(0),"wwwbatch.ini")
If FileExist( ErrIni ) Then FileDelete( ErrIni )
IntControl(73,1,0,0,0)

TKIND_ENUM     = 0 ; the TypeKind for Constants
                   ; see the help file for the other TypeKinds
;cFile          = "C:\PROGRAM FILES\ADOBE\ACROBAT 5.0\ACROBAT\ACROBAT.tlb"  ; change as needed
cFile          = "C:\WINDOWS\SYSTEM\VSFLEX7.OCX"  ; change as needed
cOut           = "c:\temp\tlcons.txt"
If FileExist( cOut )  Then FileDelete( cOut )
handle         = FileOpen(cOut,"WRITE")


BoxOpen( "TypeLib Constant Script","Opening %cFile%" )

oTLI           = ObjectOpen("TLI.TLIApplication")
oLIB           = oTLI.TypeLibInfoFromFile(cFile)
oInfo          = oLIB.TypeInfos
n              = oInfo.Count

;place for testing
;message( "Number of TypeInfos",n)
For i          = 1 To n
   oType       = oInfo.Item(i)
   If oType.TypeKind == TKIND_ENUM
      oMembers = oType.Members
      n1       = oMembers.Count
      For j    = 1 To n1
         oMem  = oMembers.Item(j)
         ; or better yet, write to your own header file
         FileWrite(handle, StrCat(oMem.Name," = ",oMem.Value ) )
         ObjectClose( oMem )
      Next
      ObjectClose( oMembers )
   Endif
   ObjectClose(oType)
Next
ObjectClose( oLIB )
ObjectClose( oTLI )
FileClose( handle )
:end
BoxShut()
Exit

:WBERRORHANDLER
cErr           = IniReadPvt("OLE Exception","TLI","Unknown Error",ErrIni )
message( Strcat("Script Error:",LastError()),cErr )
Goto end

Article ID:   W16090
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38