I have written a C dll that exports functions that return LPXXX variables.
LPMAPISESSION __stdcall GetSession();
void __stdcall CloseSession(LPMAPISESSION);
I want to be able to call these functions from VB, so I declared them like this:
Private Declare Function GetSession Lib "lgkmapi.dll" () As Long
Private Declare Function CloseSession Lib "lgkmapi.dll" (ByVal lpSession As Long)
Private Sub Command1_Click()
Dim lpSession As Long
lpSession = GetSession()
My problem is that I'm crashing on the CloseSession function.
I debug it through VC and I see that the value of lpSession returned from GetSession is 0x0168f108. From VB, the message box shows 23654664 was returned, which is the equivalent of 168f108 in hex.
When I debug the CloseSession function in VC, I see that I'm actually passing in 0x0063f3e8 for lpSession. How'd this happen? I have tried passing lpSession ByRef and ByVal in CloseSession but neither works.
Can anyone help solve this?