tpf80
8th April 2007, 00:37
Currently I am using MODULEENTRY32 windows function to get information about a process. the modBaseAddr is returned as "BYTE*". I got many errors trying to convert BYTE* to a QString.
I did some research and found that "BYTE*" is really another name for "unsigned char*". I also read that the unsigned char should work in functions requiring char, however my compiler gave me errors when trying to use the unsigned char:
qModuleBase = QString(ModuleBase);
gave the error:
calculatorform.cpp:75: error: call of overloaded `QString(unsigned char*&)' is ambiguous
C:/Qt/4.2.3/include/QtCore/../../src/corelib/tools/qstring.h:344: note: candidates are: QString::QString(const QByteArray&) <near match>
C:/Qt/4.2.3/include/QtCore/../../src/corelib/tools/qstring.h:341: note: QString::QString(const char*) <near match>
C:/Qt/4.2.3/include/QtCore/../../src/corelib/tools/qstring.h:607: note: QString::QString(const QString&) <near match>
C:/Qt/4.2.3/include/QtCore/../../src/corelib/tools/qstring.h:74: note: QString::QString(QChar) <near match>
mingw32-make[1]: *** [tmp\obj\release_shared\calculatorform.o] Error 1
I tried to convert it in a couple of ways, and these changes allowed it to be compiled:
qModuleBase = QString((char*)ModuleBase);
or
qModuleBase = QString::fromLocal8Bit((char*)ModuleBase);
However when I try and run the program with either of those fixes, it crashes. when I comment out either of those lines of code, the program runs with no errors, but of course will not display the ModuleBase.
In any case I need to convert this BYTE* or unsigned char* to a Qstring mainly so I can display the value that it returns in a QLineEdit. I actually don't care what format it is in as long as I can display it in the line edit properly.
I did some research and found that "BYTE*" is really another name for "unsigned char*". I also read that the unsigned char should work in functions requiring char, however my compiler gave me errors when trying to use the unsigned char:
qModuleBase = QString(ModuleBase);
gave the error:
calculatorform.cpp:75: error: call of overloaded `QString(unsigned char*&)' is ambiguous
C:/Qt/4.2.3/include/QtCore/../../src/corelib/tools/qstring.h:344: note: candidates are: QString::QString(const QByteArray&) <near match>
C:/Qt/4.2.3/include/QtCore/../../src/corelib/tools/qstring.h:341: note: QString::QString(const char*) <near match>
C:/Qt/4.2.3/include/QtCore/../../src/corelib/tools/qstring.h:607: note: QString::QString(const QString&) <near match>
C:/Qt/4.2.3/include/QtCore/../../src/corelib/tools/qstring.h:74: note: QString::QString(QChar) <near match>
mingw32-make[1]: *** [tmp\obj\release_shared\calculatorform.o] Error 1
I tried to convert it in a couple of ways, and these changes allowed it to be compiled:
qModuleBase = QString((char*)ModuleBase);
or
qModuleBase = QString::fromLocal8Bit((char*)ModuleBase);
However when I try and run the program with either of those fixes, it crashes. when I comment out either of those lines of code, the program runs with no errors, but of course will not display the ModuleBase.
In any case I need to convert this BYTE* or unsigned char* to a Qstring mainly so I can display the value that it returns in a QLineEdit. I actually don't care what format it is in as long as I can display it in the line edit properly.