Page 1 of 1 1
Topic Options
#191423 - 2008-12-27 12:08 AM Understanding COM
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Okay I am way over my head with my latest project.

We have recently aquired an application that comes with support for full automation via COM.

When I use the Type Library Explorer to view the COM file, I get a listing of bunch of classes with the COM, and then a list of the members of methods and property's within that class.

Using the examples that they provided, I am creating an object as such

 Code:
createobject(MyCOMLibrary.Class)


I have to use one class to connect to the server application, and then need to use a different class to retrieve needed data.

Do I have to create a new object for each new class? Or should I be creating my "root" class differently? Can I do something more like this.
 Code:
createobject(system.MyCOMLibrary)


And since someone is likely to ask ... This is for the EFT product from GlobalScape.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#191425 - 2008-12-27 05:08 AM Re: Understanding COM [Re: Gargoyle]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Have you checked their manual or their web site to see whether they have COM examples? You should then be able to adjust thses to KiXtart.
_________________________
There are two types of vessels, submarines and targets.

Top
#191428 - 2008-12-27 06:29 AM Re: Understanding COM [Re: Sealeopard]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Their manual provides 3 examples, and they are confusing at best. Most of it reads like this.

 Quote:

Use the ICISite Interface GetAuthManagerID method to identify or retrieve the authentication manager ID of a site. The authentication manager ID is the type of authentication used (GS Auth, NT/AD, or ODBC).

Signature:

HRESULT GetAuthManagerID([out, retval] long *prop);


Where the ICISite Interface is a class in the DLL.

You can see the manual here...

http://help.globalscape.com/help/eft5_com/
_________________________
Today is the tomorrow you worried about yesterday.

Top
#191429 - 2008-12-27 06:32 AM Re: Understanding COM [Re: Gargoyle]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
So what kind of data are you needing when using this?
Top
#191431 - 2008-12-27 06:47 AM Re: Understanding COM [Re: Allen]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Currently I need to list all of the "Events" within a single site and then ensure that they are disabled.

Among other things. I can post some of my code on Monday if it would help me figure out what I am doing.

I already have been able to list all of the Users in a given site and extract what their email address is, but this "Event" stuff is killing me.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#191462 - 2008-12-29 12:16 PM Re: Understanding COM [Re: Gargoyle]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Haven't read the manual yet, but the proper code should be
 Code:
$obj = CreateObject("MyCOMLibrary.Class")

Top
#191463 - 2008-12-29 12:17 PM Re: Understanding COM [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
As the manual points out, this should be the kix code:
 Code:
$SFTPServer = CreateObject("SFTPCOMInterface.CIServer")

Top
#191464 - 2008-12-29 12:30 PM Re: Understanding COM [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
I've translated this sample script for you, maybe it helps:
 Code:
; FILE: CreateUserListSpreadSheet
; CREATED: 13 OCT 2004 GTH
; PURPOSE: List the users of a site and create an excel spreadsheet.
;

$SFTPServer = CreateObject("SFTPCOMInterface.CIServer")
$CRLF = Chr(13)+Chr(10)
$txtServer = "192.168.134.142"
$txtPort =  "1000" 
$txtUserName = "admin"
$txtPassword = "admin"

$SFTPServer.Connect($txtServer, $txtPort, $txtUserName, $txtPassword)

If @ERROR <> 0
  ? "Error connecting to '"+$txtServer+":"+$txtPort+"' -- "@SERROR+" ["+CStr(@ERROR)+"]"
  Exit 255
Else
  ? "Connected to " + $txtServer
EndIf

$Sites = $SFTPServer.Sites
$oExcel = CreateObject("Excel.Application")
$oExcel.visible = 1
$oWorkbook = $oExcel.Workbooks.Add
For $i=0 To $SFTPServer.Sites.Count-1
  $theSite = $Sites.Item($i)
  $theSheet = $oWorkbook.Worksheets.add
  $theSheet.name = $theSite.Name
  $theSheet.Cells(1, 1) = "Users:"
  $arUsers = $theSite.GetUsers()
  For $j=0 To UBound($arUsers)
    $theSheet.Cells(($j+2), 1) = $arUsers($j)
  Next
  $theSheet.Columns("A:A").EntireColumn.Autofit
Next

$oExcel = ""
$SFTPServer.Close
$theSite = ""
$SFTPServer = ""

Top
#191466 - 2008-12-29 01:41 PM Re: Understanding COM [Re: Arend_]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Apronk, thanks, but I was able to get that part working okay. I will post my script later today so all can see what I am attempting.

Where I am having a problem is in an event class that they just exposed in the COM, and is not in their online documentation.

In specific I do not understand how to read this...
 Quote:

HRESULT GetAuthManagerID([out, retval] long *prop);
_________________________
Today is the tomorrow you worried about yesterday.

Top
#191472 - 2008-12-29 02:49 PM Re: Understanding COM [Re: Gargoyle]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
To be honest, due to the properties I don't fully understand it either. From what I gather it the [out, retval] is a returning variable going out (something KiX doesn't support) the variable is of the type long (int).

But I might be reading it totally wrong.

Edit: Apparantly [out, retval] means that it is a returning variable as I just said, and the variable is of the type long, the numeric index of the property, I guess. However You won't be able to use it in KiX. KiX doesn;t support OUT paramenters, VBS does though....

I've asked for this OUT parameter support a couple of times already...


Edited by apronk (2008-12-29 02:57 PM)

Top
#191474 - 2008-12-29 03:56 PM Re: Understanding COM [Re: Arend_]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Ok, so I may have to switch to PowerShell for this then. Here is the current code that I am working with, but will see what I can do with PS.

 Code:

$SO=SetOption("Explicit", "ON")
$SO=SetOption("NoMacrosInStrings", "ON")
$SO=SetOption("NoVarsInStrings", "ON")
$SO=SetOption("WrapAtEOL", "ON")

;  Variable Declarations
Dim $o_Server,$a_Sites,$s_Counter,$s_Site,$s_Events

;  Instatiate the SFTP COM Object
$o_Server = CreateObject(SFTPCOMInterface.CIServer)

;  Connect to the server
$o_Server.Connect('10.10.0.23','3000','admin','password')

;  Retrieve a list of Sites
$a_Sites=$o_Server.Sites

;  See if the Site is stopped, if not Stop it
For $s_Counter = 0 to UBound($a_Sites)
	$s_Site = $o_Server.Sites.Item($s_Counter)
	If $s_Site.IsStarted = 'True'
		$s_Site.Stop()
	EndIf
Next

;  Stop the EFT Server Service

Shell '%comspec% sc \\server stop "GlobalScape EFT Server"'

;  Wait for the service to stop

While WMIService("GlobalScape EFT Server","Query",,"\\server") <> "Stopped"

Loop

;  Create backup of config on Server01  and Server02 to the DFS mount
Copy "\\server\e$\Globalscape\ftp.dat" "\\server03\eftdata\eftconfig\server_config\ftp_"+Join(Split(@DATE,"/"))+".bak"
Copy "\\server01\e$\Globalscape\ftp.dat" "\\server03\eftdata\eftconfig\server01_config\ftp_"+Join(Split(@DATE,"/"))+".bak"

;  Overwrite the config on Server with the Master copy
Copy "\\server01\e$\globalscape\ftp.dat" "\\server\e$\globalscape\"


;  Start the EFT Server Service
Shell '%comspec% sc \\server start "GlobalScape EFT Server"'

;  Wait for the service to start
While WMIService("GlobalScape EFT Server","Query",,"\\server") <> "Running"

Loop

;  Stop any sites that came up running
For $s_Counter = 0 to UBound($a_Sites)
	$s_Site = $o_Server.Sites.Item($s_Counter)
	If $s_Site.IsStarted = 'True'
		$s_Site.Stop()
	EndIf
Next

;  Change the IP's to the correct one for each site.
For $s_Counter = 0 to UBound($a_Sites)
	$s_IP = ReadProfileString("\\server03\eftdata\eftconfig\globalscape\config.ini","Sites",$a_Sites[$s_Counter])
	$s_Site = $o_Server.Sites.Item($s_Counter)
	$s_Site.SetIP("10.10.0."+$s_IP)
	
;  Need to find a way to change the gateway address as well

;  Turn off all the event rules
	$s_Events = $s_Site.

Next





Function WMIService($service,$action,optional $startmode,optional $computer)
;Removed to make a shorter post	
_________________________
Today is the tomorrow you worried about yesterday.

Top
#191475 - 2008-12-29 04:06 PM Re: Understanding COM [Re: Gargoyle]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Looks good, just a suggestion... you can stop and start services trough the same WMI manor too.
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.064 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org