Hallo everibody,
I'm new in programming remedy's C api from VB6 and i'm having many problems using it. I'm trying to use Initialize function but the error it give me back is "Invalid Conventional Call to Dll". It looks like i gave the wrong argument. I've copied the structure from C and i think i passed in the wrong way the variables. Can anyone help me? Thanks a lot!!!!
here it is the code:
Type ARAccessNameType
value As String
End Type
Type ARMessageText
value As String
End Type
Type ARAppendText
value As String
End Type
Type ARTimestamp
value As Long
End Type
Type ARControlStruct
cachID As Long
operationTime As ARTimestamp
user As ARAccessNameType
password As ARAccessNameType
language(0 To 15) As Byte
sessionID As Long
authString(0 To 254) As Byte
server(0 To 64) As Byte
End Type
Type ARStatusStruct
messageType As Integer
messageNum As Long
messageText As ARMessageText
appendText As ARAppendText
End Type
Type ARStatusList
numItems As Integer
statusList As ARStatusStruct
End Type
Private Const AR_RETURN_OK = 0
Private Const AR_RETURN_WARNING = 1
Private Const AR_RETURN_ERROR = 2
Private Const AR_RETURN_FATAL = 3
Private Const AR_RETURN_BAD_STATUS = 4
Private Declare Function ARInitialization Lib "arapi51.dll" (ByRef x As Any, ByRef y As Any) As Long
'Copia una struttura Type su un array di Byte. Bisogna passare
'indirizzo della struttura Type con la funzione VarPtr() e la sua
'lunghezza calcolata con LenB(). L'array DEVE essere vuoto per poter
'essere ridimensionato
Public Sub CopyTypeToBYTE(ByVal pType As Long, ArrayDest() As Byte, ByVal iNElements As Integer, Optional ByVal iBase As Integer = 0)
ReDim ArrayDest(iBase To iNElements - 1)
CopyMemory ArrayDest(iBase), ByVal pType, iNElements
End Sub
'Copia un array di Byte su una struttura Type
Public Sub CopyBYTEToType(ArraySource() As Byte, ByVal pType As Long, _
ByVal iNElements As Integer)
Dim iInizio As Integer
iInizio = LBound(ArraySource)
CopyMemory ByVal pType, ArraySource(iInizio), iNElements
End Sub
Public Function prova(ww As Variant, wwq As Variant) As Byte
Dim messaget As ARMessageText
Dim appText As ARAppendText
Dim x As ARControlStruct
Dim y As ARStatusList
Dim z As ARStatusStruct
Dim mtime As ARTimestamp
Dim user As ARAccessNameType
Dim pwd As ARAccessNameType
Dim ret As Long
messaget.value = Chr(33)
appText.value = Chr(33)
user.value = "pippo"
pwd.value = "pluto"
mtime.value = 54354346
' valorizzo ARStatusStruct
z.messageNum = 0
z.messageType = 0
z.messageText = messaget
z.appendText = appText
' valorizzo ARControlStruct
x.cachID = 0
x.operationTime = mtime
x.password = pwd
x.language(0) = 32
x.server(0) = 32
x.user = user
x.sessionID = 0
x.authString(0) = 32
' valorizzo ARStatusList
y.numItems = 0
y.statusList = z
ret = ARInitialization(x, y)