In my QT project, I'm accessing a DLL which acts as a bridge between my application and another platform. I note first of all that currently all is working very well!

I have one piece of code that requires me to include some of the standard Windows dlls in my build, and I'd like to get rid of them by using native QT code. The code is below.

Qt Code:
  1. QString GlobalSettings::mql4_ansi2unicode(quintptr _ptrStringMemory)
  2. {
  3. int szString=0;
  4. uchar *ucValue=NULL;
  5.  
  6. if (_ptrStringMemory == 0)
  7. {
  8. return ("");
  9. }
  10. else
  11. {
  12. szString = lstrlenA((LPCSTR)_ptrStringMemory);
  13.  
  14. ucValue = new uchar[szString+1];
  15. for (int i=0; i< szString+1; i++) // Allow for Null
  16. ucValue[i]=0;
  17.  
  18. RtlMoveMemory((void *)ucValue, (void *)_ptrStringMemory, szString + 1);
  19. QString strptr((const char *)ucValue);
  20. delete [] ucValue;
  21. LocalFree((HLOCAL)_ptrStringMemory);
  22. return (strptr);
  23. }
  24. }
To copy to clipboard, switch view to plain text mode 

An example of how this code is used is as follows.

Qt Code:
  1. QString Bridge::Test()
  2. {
  3. quintptr Testptr=0;
  4.  
  5. typedef int (__stdcall *MyPrototype)();
  6. MyPrototype myFunction =
  7. (MyPrototype) QLibrary::resolve("NFX.Trading.Panel.Bridge.dll", "Test");
  8. if (myFunction)
  9. Testptr = myFunction();
  10. return(globalclass.mql4_ansi2unicode(Testptr));
  11. }
To copy to clipboard, switch view to plain text mode 

The function in the DLL returns a string. I need to check the string to see if I'm communicating with the bridge DLL okay.
While I understand in general what the mql4_ansi2unicode function is doing, I don't know how to do the same thing in QT.

Can anyone help?
Thanks