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