VB Translation

VB Translation

Postby Rick Lipkin » Mon Feb 02, 2009 6:50 pm

To All

I have VB 6 program I wish to translate. This program uses an external dll called "WxCrypto5.dll" which contains the logic to return a hashed credential from the Legatto AX ( application xtender ) Imaging API.

It appears to be using ADO to pass a very simple set of parameters to the function which I assume is in the .dll

WxCredentials = WXCrypt.GenUrlCryptString("", UserName, Password, WxKey) where username and password I know and WxKey is the parameter "Password"

Here is the VB code :
Code: Select all  Expand view
VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   4170
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7005
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   4170
   ScaleWidth      =   7005
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1
      Caption         =   "Get Credentials"
      Height          =   495
      Left            =   4440
      TabIndex        =   8
      Top             =   3480
      Width           =   2415
   End
   Begin VB.TextBox txtCreds
      Height          =   375
      Left            =   360
      TabIndex        =   5
      Top             =   3000
      Width           =   6495
   End
   Begin VB.TextBox txtWxKey
      Height          =   375
      Left            =   360
      TabIndex        =   4
      Text            =   "Password"
      Top             =   2160
      Width           =   2175
   End
   Begin VB.TextBox txtPassword
      Height          =   375
      Left            =   360
      TabIndex        =   2
      Top             =   1440
      Width           =   2175
   End
   Begin VB.TextBox txtUserName
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Top             =   720
      Width           =   2175
   End
   Begin VB.Label Label3
      Caption         =   "Credentials:"
      Height          =   375
      Left            =   360
      TabIndex        =   7
      Top             =   2760
      Width           =   2055
   End
   Begin VB.Label Label4
      Caption         =   "Wx Key:"
      Height          =   375
      Left            =   360
      TabIndex        =   6
      Top             =   1920
      Width           =   2055
   End
   Begin VB.Label Label2
      Caption         =   "Password:"
      Height          =   375
      Left            =   360
      TabIndex        =   3
      Top             =   1200
      Width           =   2055
   End
   Begin VB.Label Label1
      Caption         =   "User Name:"
      Height          =   375
      Left            =   360
      TabIndex        =   1
      Top             =   480
      Width           =   2055
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
   
    If txtUserName = "" Then
        MsgBox "You must supply a User Name!"
        Exit Sub
    End If
   
    txtCreds = WxCredentials(txtUserName, txtPassword, "password")
End Sub

Private Function WxCredentials(ByVal UserName As String, ByVal Password As String, ByVal WxKey As String) As String
    Dim WXCrypt As Object
   
    On Error GoTo WxCredentials_Err
    Set WXCrypt = CreateObject("WxCrypto.WxCryptoCom5")
    WxCredentials = WXCrypt.GenUrlCryptString("", UserName, Password, WxKey)

CleanUp:
    Set WXCrypt = Nothing
    On Error GoTo 0
    Exit Function

WxCredentials_Err:
    GoTo CleanUp
End Function


and here is my translation :
Code: Select all  Expand view
// Main.prg

#INCLUDE "FIVEWIN.CH"

//------------------------
Func Main()

LOCAL cFILE, aDIR, dEXE, mSTART, SAYING, hDLL
LOCAL oWX, cWxCredentials

//-- get timestamp on .exe //

cFILE := GetModuleFileName( GetInstance() )
aDIR  := DIRECTORY( cFILE )
dEXE  := aDIR[1] [3]

// where .exe started from is default directory //

mSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,mSTART-1)

aDIR := NIL

SET DEFA to ( cDEFA )
IF .not. FILE( cDEFA+"\WXCRYPTO5.DLL" )
   SAYING := "Could not find the file WxCrypto5.dll"
   MsgInfo( saying )
   RETURN(NIL)
ENDIF

hDLL := LoadLibrary( cDEFA+"\WXCRYPTO5.DLL" )

oWx := TOleAuto():New( "WxCrypto.WxCryptoCom5" )
cWxCredentials := oWx:GenUrlCryptString("", "lwm_view", "lwm_view", "Password" )

MsgInfo( cWxCredentials )

oWx:Close()
FreeLibrary( hDLL )

RETURN(NIL)


The program errors out with this message :
Code: Select all  Expand view
===========
   Path and name: C:\FOX\WxCreds\WxLogin.Exe (32 bits)
   Size: 1,645,568 bytes
   Time from start: 0 hours 0 mins 0 secs
   Error occurred at: 02/02/09, 13:34:56
   Error description: Error TOleAuto/-1  CO_E_CLASSSTRING: TOLEAUTO:NEW
   Args:
     [   1] = C   WxCrypto.WxCryptoCom5

Stack Calls
===========
   Called from:  => THROW(0)
   Called from: source\rtl\win32ole.prg => TOLEAUTO:NEW(335)
   Called from: MAIN.PRG => MAIN(33)



I have looked at the WxCrypro5.dll with BRW and it contains:

REGISTRY
102
TYPELIB
1
STRINGTABLE
100
VERSIONINFO
1

In the stringtable is 100, "WxCrypto" along with 8 other lines .. Hopefully someone could translate the VB code or give me some suggestions on how to replicate the ADO calls to work this .dll library ??

I am sure many of you will have questions .. please feel free to ask.

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: VB Translation

Postby Antonio Linares » Mon Feb 02, 2009 7:10 pm

Rick,

Please try this:

oWx := CreateObject( "WxCrypto.WxCryptoCom5" )

instead of:

oWx := TOleAuto():New( "WxCrypto.WxCryptoCom5" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: VB Translation

Postby Rick Lipkin » Mon Feb 02, 2009 7:43 pm

Antonio

Still getting the same error :

Code: Select all  Expand view
Application
===========
   Path and name: C:\FOX\WxCreds\WxLogin.Exe (32 bits)
   Size: 1,645,568 bytes
   Time from start: 0 hours 0 mins 0 secs
   Error occurred at: 02/02/09, 14:41:31
   Error description: Error TOleAuto/-1  CO_E_CLASSSTRING: TOLEAUTO:NEW
   Args:
     [   1] = C   WxCrypto.WxCryptoCom5

Stack Calls
===========
   Called from:  => THROW(0)
   Called from: source\rtl\win32ole.prg => TOLEAUTO:NEW(335)
   Called from: source\rtl\win32ole.prg => CREATEOBJECT(73)
   Called from: MAIN.PRG => MAIN(33)


Rick
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: VB Translation

Postby Antonio Linares » Mon Feb 02, 2009 9:46 pm

Rick,

Have you registered the DLL using regsvr32.exe ?

Is the VB example working properly in your computer ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: VB Translation

Postby Rick Lipkin » Mon Feb 02, 2009 10:47 pm

Antonio

We have a document imaging system and we use a propriatary API to retrieve documents. The Vendor shared this code with me in the hopes we could use it to integrate into our programs.

I did speak brieflly with the Vender this afternoon and he mentioned registering the .dll as well .. which is not exactically what I wanted to hear especially when I have an install base of about 1000 users for document imaging and retrieval.

I did put the VB project into Visual Studio and was able to compile the program .. however I did not get any return values from the Vendors VB program ..

The Vendor and I will be talking more in-depth tomorrow .. I will keep you informed and let you know if I can get both examples working ..

Many Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: VB Translation

Postby Rick Lipkin » Thu Feb 05, 2009 9:45 pm

To All

Registering the .dll was the key here ..

Thanks
Rick Lipkin

Code: Select all  Expand view
// Main.prg

#INCLUDE "FIVEWIN.CH"

//------------------------
Func Main()

LOCAL cFILE, aDIR, dEXE, mSTART, SAYING, hDLL
LOCAL oWX, cWxCredentials

//-- get timestamp on .exe //

cFILE := GetModuleFileName( GetInstance() )
aDIR  := DIRECTORY( cFILE )
dEXE  := aDIR[1] [3]

// where .exe started from is default directory //

mSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,mSTART-1)

aDIR := NIL

// must have already registered wxcrypto5.dll
// no need to load

oWx := CreateObject( "WxCrypto.WxCryptoCom5")
cWxCredentials := oWx:GenUrlCryptString("", "lwm_view", "lwm_view", "password" )

MsgInfo( cWxCredentials )

RETURN(NIL)

User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests