M
Mansoor
Hi All,
I wrote a wrapper dll 'SmartTransfer.dll' that using rapi APIs
(CeRapiInitEx, CeReadFile, CeWriteFile, CeRapiUninit).I have tested
'SmartTransfer.dll' and connected HHT with VB 6 Application
through wrapper dll and It is working fine but when I called this
wrapper dll on ASP page ,it is not working and not connected with HHT.
Then I logged my code and found that CeRapiInitEx return less than 0
value .Can someone help me on this regards and its is possible that I
used rapi.dll with ASP 3.
code is here :
Public Function RapiConnect() As Boolean
'Initiates a connection and returns true
' if it connected, false if it did not.
' Dim fs As New FileSystemObject
' Dim ts As TextStream
' Set ts = fs.CreateTextFile("C:\newman.txt ", True)
' ts.WriteLine "Start"
Dim pRapiInit As RAPIINIT
Dim dwWaitRet, dwTimeout As Long
Dim hr As Long
On Error GoTo RapiConnect_Err
pRapiInit.cbSize = Len(pRapiInit)
pRapiInit.heRapiInit = 0
pRapiInit.hrRapiInit = 0
hr = E_FAIL
dwWaitRet = 0
dwTimeout = 10 * ONE_SECOND 'However long you want to wait
'Call CeRapiInitEx one time.
hr = CeRapiInitEx(pRapiInit)
If hr < 0 Then 'FAILED
GoTo Failed
End If
' ts.WriteLine "hr is not failed"
'Wait for the RAPI event until timeout.
'Use the WaitForSingleObject function for the worker thread
'Use the WaitForMultipleObjects function if you are also waiting for
other events.
dwWaitRet = WaitForSingleObject(pRapiInit.heRapiInit, dwTimeout)
If dwWaitRet = 0 Then 'WAIT_OBJECT_0
'If the RAPI init is returned, check result
' ts.WriteLine "dwWaitRet SUCCEEDED"
If pRapiInit.hrRapiInit >= 0 Then 'SUCCEEDED
' ts.WriteLine "hrRapiInit SUCCEEDED"
GoTo Succeeded
Else
' ts.WriteLine "hrRapiInit failed"
GoTo Failed
End If
Else
' ts.WriteLine "dwWaitRet failed"
'Timeout or failed.
GoTo Failed
End If
'success
Succeeded:
'Now you can make RAPI calls.
'ts.Close
'Set ts = Nothing
'Set fs = Nothing
RapiConnect = True
Exit Function
Failed:
'Uninitialize RAPI if you ever called CeRapiInitEx.
If hr >= 0 Then 'SUCCEEDED
Call CeRapiUninit
End If
'ts.Close
'Set ts = Nothing
'Set fs = Nothing
RapiConnect = False
Exit Function
RapiConnect_Err:
RapiConnect = False
End Function
Regards,
Mansoor Ali
I wrote a wrapper dll 'SmartTransfer.dll' that using rapi APIs
(CeRapiInitEx, CeReadFile, CeWriteFile, CeRapiUninit).I have tested
'SmartTransfer.dll' and connected HHT with VB 6 Application
through wrapper dll and It is working fine but when I called this
wrapper dll on ASP page ,it is not working and not connected with HHT.
Then I logged my code and found that CeRapiInitEx return less than 0
value .Can someone help me on this regards and its is possible that I
used rapi.dll with ASP 3.
code is here :
Public Function RapiConnect() As Boolean
'Initiates a connection and returns true
' if it connected, false if it did not.
' Dim fs As New FileSystemObject
' Dim ts As TextStream
' Set ts = fs.CreateTextFile("C:\newman.txt ", True)
' ts.WriteLine "Start"
Dim pRapiInit As RAPIINIT
Dim dwWaitRet, dwTimeout As Long
Dim hr As Long
On Error GoTo RapiConnect_Err
pRapiInit.cbSize = Len(pRapiInit)
pRapiInit.heRapiInit = 0
pRapiInit.hrRapiInit = 0
hr = E_FAIL
dwWaitRet = 0
dwTimeout = 10 * ONE_SECOND 'However long you want to wait
'Call CeRapiInitEx one time.
hr = CeRapiInitEx(pRapiInit)
If hr < 0 Then 'FAILED
GoTo Failed
End If
' ts.WriteLine "hr is not failed"
'Wait for the RAPI event until timeout.
'Use the WaitForSingleObject function for the worker thread
'Use the WaitForMultipleObjects function if you are also waiting for
other events.
dwWaitRet = WaitForSingleObject(pRapiInit.heRapiInit, dwTimeout)
If dwWaitRet = 0 Then 'WAIT_OBJECT_0
'If the RAPI init is returned, check result
' ts.WriteLine "dwWaitRet SUCCEEDED"
If pRapiInit.hrRapiInit >= 0 Then 'SUCCEEDED
' ts.WriteLine "hrRapiInit SUCCEEDED"
GoTo Succeeded
Else
' ts.WriteLine "hrRapiInit failed"
GoTo Failed
End If
Else
' ts.WriteLine "dwWaitRet failed"
'Timeout or failed.
GoTo Failed
End If
'success
Succeeded:
'Now you can make RAPI calls.
'ts.Close
'Set ts = Nothing
'Set fs = Nothing
RapiConnect = True
Exit Function
Failed:
'Uninitialize RAPI if you ever called CeRapiInitEx.
If hr >= 0 Then 'SUCCEEDED
Call CeRapiUninit
End If
'ts.Close
'Set ts = Nothing
'Set fs = Nothing
RapiConnect = False
Exit Function
RapiConnect_Err:
RapiConnect = False
End Function
Regards,
Mansoor Ali