Unable to pass String argument

abghosh

New member
Joined
Mar 7, 2010
Messages
2
Programming Experience
Beginner
Hi
I am a newbie to .net.
The problem that I am facing is that I want to call a shared DLL created by qt4. Now reading the result from the DLL file is working well and good. But the problem arised while passing arguments required by the function in the dll file.

The argument (both string or int) is not passed properly. Suppose I pass an integer argument 8, but 1 is passed. Whatever is my input only 1 is passed.

Can any bosy pls help me with this problem.

Thanks in advance.
 
There's really nothing we can tell you from that. If the DLL code is written correctly and your code is written correctly then passing an argument will work as it should. If it's not working then there's either an issue with the DLL or an issue with your code. As we haven't seen anything of either there's no way for us to say any more.
 
Hi jmcilhinney

Pls find below the codes:
Code for dll:
VB.NET:
const char* QtEngineDll::randInt(char** y)
{
    /*char* result = "";
    qstrcpy(result, *y);*/
    QTextCodec *codec = QTextCodec::codecForName("KOI8-R"); // get the codec for KOI8-R
    QString unicodeString = codec->toUnicode(*y);
    QString ret = unicodeString;
    QString fileName = QDir::currentPath() + "/Test.txt";
    QFile file(fileName);
    file.open(QIODevice::Append | QIODevice::Text);
    file.write(*y);
    file.write("\n");

    return ret;
}

Code for calling it in Vb.net
VB.NET:
<DllImport("G:\Varen_CS\02_Projects\01_Softwares\highFreqTrad\test\debug\test.dll", _
        SetLastError:=True, CharSet:=CharSet.Auto, _
        ExactSpelling:=True, _
        CallingConvention:=CallingConvention.StdCall)> _
    Private Shared Function _ZN11QtEngineDll7randIntEPPc(ByRef u As String) As String
    End Function

And here is the function call:
VB.NET:
Dim res As String
res = _ZN11QtEngineDll7randIntEPPc("Abhijit")

Hope this gives you some idea about it.
 
Back
Top