Help - Calling ActiveX DLL function from VB and C++ returns different values 
Author Message
 Help - Calling ActiveX DLL function from VB and C++ returns different values

I call functions in an ActiveX DLL from both VB and C++ but I'm getting
different results from each. I think I'm doing the same thing in VB and C++.
If anyone can shed any light on this I'd be most grateful. The VB and C++
code are below:

VB:
Project has a reference to duspd.dll

    Dim dxz As New DUS
    Dim bvc As New BPD
    Dim enc As String

    dxz.Key = "LIC"
    enc = bvc.Encode(dxz.Encrypt("ABCDE1"))

    'The value of enc above is, say, "QWE"

In C++, I do the following:
#import "duspd.dll" rename("NO_ERROR", "BPD_NO_ERROR")
extern "C" __declspec(dllexport) int ValR(char *,char *);
int
ValR(char *a, char *b)
{
    HRESULT hr;
    DUSPDLib::_DUSPtr dxz;
    DUSPDLib::_BPDPtr bvc;
    BSTR key, ld, b3;
    _bstr_t b1, b2;

    hr = CoInitialize(NULL);
    hr = dxz.CreateInstance (__uuidof (DUSPDLib::DUS));
    hr = bvc.CreateInstance (__uuidof (DUSPDLib::BPD));
    // no errors from above

    key = SysAllocString (L"LIC");
    d56->PutKey(&key);

    ld = SysAllocString (L"ABCDE1");
    b1 = dxz->Encrypt(&ld);
    b3 = SysAllocString(static_cast<const wchar_t*>(b1));
    b2 = bvc->Encode(&b3);

    fprintf (f, "b2=%s\n", (char *)b2);

    // **** The value I get when I print b2 to file is not "QWE" as I
expected, but some other string

    SysFreeString......
    bvc.Release();
    dxz.Release();
    CoUninitialize();

Quote:
}



Tue, 12 Mar 2002 03:00:00 GMT  
 Help - Calling ActiveX DLL function from VB and C++ returns different values
Please ignore above message. It does work. I was doing something wrong.
Sorry for any inconvenience.


Tue, 12 Mar 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. localtime function returns different values for different winnt operating systems

2. Return values from VB CallBack Function to VC Dll

3. Return a string from a DLL function called by VB

4. _filelength() returns -1 in C++ 1.52 DLL when called from VB 3.0

5. C++ calling VB DLL returning VARIANT

6. How do you call VB ActiveX DLL functions from VC

7. GetCurSel() for a CComboBox is returns 2 different values on consecutive calls

8. How to call a function in VB dll by C++

9. function parameters and return values aren't changed by function call

10. Calling a VB function/procedure from Visual C++ DLL

11. values do not reach the dll in a dll-call of VB

12. values do not reach the dll in a dll-call of VB

 

 
Powered by phpBB® Forum Software