这是什么错误?C ++到Java,帮助!!! [英] what's this error???C++ to java ,help!!!!

查看:120
本文介绍了这是什么错误?C ++到Java,帮助!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//this''s jni function in dll;

JNIEXPORT jstring JNICALL Java_vc_CallVc_getActiveWindowTitle//get title
(JNIEnv * jn, jclass)
{
             jstring str;
            const char *strTitle     =GetStringUTFChars( str , 0);
           ::GetWindowText(::GetForegroundWindow(),(LPSTR)strTitle,MAX_PATH);
             char  srtMsg[MAX_PATH];
            sprintf(srtMsg,this dialog title is:%s,strTitle);
            AfxMessageBox(strTitle);
            jn->ReleaseStringChars(str,0);
            return  (jstring)strTitle;//error  ???
}


//me demo dialog function for vc++2005


void CJniSparkDlg::OnBnClickedCancel6()
{
    // TODO: Add your control notification handler code here
    JNIEnv *a;
    jclass c;
    Java_vc_CallVc_screenCameraShot(a,c);
}


代码编译成功,但是出现运行时错误.你能帮我吗?
:sigh::sigh:
请给我发邮件:*删除邮件*
谢谢.


The code compiles successfully, but I get a runtime error. Can you help me?
:sigh: :sigh:
Please send me a mail: *REMOVED MAIL*
Thank you.

推荐答案

如果您发布(a)您正在使用的Java和(b)人们可能有什么帮助,那是什么错误呢? .

我对JNI一无所知,但是您是否考虑过在第二遍代码中您使用的是未初始化的变量?

在第一个块中,您还将const指针转换为非const(取决于是否有空,取决于GetStringUTFChars的语义).
干杯,

Ash
If you post (a) the Java you''re using and (b) what the error is people might be able to help a bit more.

I don''t know anything about JNI but have you considered that in the second lump of code you''re using an uninitialised variable?

In the first lump you also cast a const pointer to a non-const (which may or may not be a no-no, depends on the semantics of GetStringUTFChars).

Cheers,

Ash


没人帮我吗?????:confused:
Nobody help me ?????:confused:


这篇关于这是什么错误?C ++到Java,帮助!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆