Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//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);
}

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.
Posted
Updated 23-Nov-10 18:43pm
v10
Comments
Indivara 23-Nov-10 22:41pm    
(1) Deleted email address. Nobody but spammers will reply to you.
(2) You need to say what the error is.
JF2015 24-Nov-10 0:43am    
Edited: Removed mail address.

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
 
Share this answer
 
Nobody help me ?????:confused:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900