QString and BSTR
-
hi to everyone
i have a c# dll that i use it via dumpcpp and active qt
it works correctly except when i call a function that uses BSTR that dumpcpp converted to QString
how can i solve this problem?
how can i convert qString to bstr? -
something like this ...
@
BSTR test = SysAllocString(QString::utf16());
// to do what you need with "test"
SysFreeString(test)
@ -
i want to set a Qstring variable to my Bstr and
i want to set a Bstr variable to my QString
can you give me example? -
[quote author="kitten" date="1316004185"]i want to set a Qstring variable to my Bstr[/quote]
previous example not work ? ... or some minimal compilable example would be ...
@
QString string("whatever string");
BSTR bstr = SysAllocString(string.utf16());
// to do what you need with "bstr"
SysFreeString(bstr);@
[quote author="kitten" date="1316004185"]i want to set a Bstr variable to my QString [/quote]
QString string = QString::fromUtf16(yourBSTR); -
thanks alot for your answer
but i use this code and it get me error
@ bool qax_result;
QString st("mil");
BSTR test = SysAllocString(st.utf16());
void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)&test};
qt_metacall(QMetaObject::InvokeMetaMethod, 244, _a);
SysFreeString(test);
return qax_result;@
it is compiled successfully but when i run it, it get me error -
Hi kitten,
where do you get which error?
Did you try to debug it?The conversion from QString to BSTR looks generally correct.
-
By the way, do you need a BSTR*?
in the parameters, you write:@
(void*)&test...
@a BSTR is already a pointer....
-
i use this but it get me error again
@void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)test};@
it get me error on this file
qatomic_windows.h
on function
@inline bool QBasicAtomicInt::ref()@ -
I did a little test, and it works perfectly:
@
QString string("test");
BSTR bstr = SysAllocString(reinterpret_cast<const OLECHAR*>(string.utf16()));
char testing[] = {bstr[0], bstr[1], bstr[2], bstr[3], '\0'};
qDebug(testing);
SysFreeString(bstr);
@debug window show "test"
-
Just out of curiosity, if you delete last parameter(test) from _a array, the problem still exists ?
-
[quote author="kitten" date="1316007780"]i use this but it get me error again
@void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)test};@
it get me error on this file
qatomic_windows.h
on function@
inline bool QBasicAtomicInt::ref()
@
[/quote]Which error message do you get???
this is just a parameter assignement, nothing else
-
it work correctly
do you what i want to do?
i have a .net dll now i want to write a program for it
i use dumpcpp to use it , it works correctly and this functions work correctly too
but when i send a text of other languages like persian to this dll it show me ???? in replace of my text -
!http://www.pic.iran-forum.ir/images/81rzhse7v2t3wujmtb1.jpg(error)!
[quote author="Gerolf" date="1316008510"][quote author="kitten" date="1316007780"]i use this but it get me error again
@void _a[] = {(void)&qax_result, (void*)&Row, (void*)&Col, (void*)test};@
it get me error on this file
qatomic_windows.h
on function
@inline bool QBasicAtomicInt::ref()@[/quote]Which error message do you get???
this is just a parameter assignement, nothing else[/quote]
-
which is the call stack?
-
what do you mean by call stack?
-
In Visual Studio is: Debug -> Windows -> Call Stack
-
this is my call stack when i got error
!http://www.pic.iran-forum.ir/images/vpo7zgu8y0gdpbw6id4l.jpg(call stack)! -
[quote author="kitten" date="1316008652"]it work correctly
i use dumpcpp to use it , it works correctly and this functions work correctly too
but when i send a text of other languages like persian to this dll it show me ???? in replace of my text
[/quote]What work correctly ? When your program crashes ?
Also for persian and arabic conversion, maybe "PAText wiki":http://developer.qt.nokia.com/wiki/QPlugs_PAText_Add_Persian_and_Arabic_support_to_WindowsCE_Mobile_applications will help you -
it is generated with dumpcpp
if i use the default it work corrctly on english language
but in persian language it doesn't work correctly -
How do you enter persian text?
The shown call stack is too short, please copy it out of the call stack window and post it as text.