Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4014200
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:28:05+00:00 2026-05-20T09:28:05+00:00

The C++ side looks like this: JNIEXPORT jint JNICALL Java_Myclass_showMessage (JNIEnv* env, jobject obj,

  • 0

The C++ side looks like this:

JNIEXPORT jint JNICALL Java_Myclass_showMessage (JNIEnv* env, jobject obj, jstring title, jstring message, jint type)
{
    const char* _title = env->GetStringUTFChars(title, 0);
    const char* _message = env->GetStringUTFChars(message, 0);
    const int result = MessageBox(NULL, (LPCTSTR) _message, (LPCTSTR) _title, type);
    env->ReleaseStringUTFChars(title, _title);
    env->ReleaseStringUTFChars(message, _message);
    return result;
}

And java side:

int result = showMessage("caption", "Hello!", 0);

However when i call the exported function from java this is what i get:

http://i54.tinypic.com/wu5hs0.png

Any idea what could cause this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:28:05+00:00Added an answer on May 20, 2026 at 9:28 am

    Use MessageBoxA – MessageBox autoselects the wide or mbcs version based on your projects Unicode/MBCS setting.

    If you need to cast to LPCTSTR that’s an indication something’s wrong.

    Alternatively, use GetStringChars and MessageBoxW, in this case you may need to cast depending on what jchar is defined as.

    EDIT: Sample code

    JNIEXPORT jint JNICALL Java_Myclass_showMessage (JNIEnv* env, jobject obj, jstring title, jstring message, jint type)
    {
        const jchar* _title = env->GetStringChars(title, 0);
        const jchar* _message = env->GetStringChars(message, 0);
        const int result = MessageBox(NULL, (wchar_t *) _message, (wchar_t *) _title, type);
        env->ReleaseStringChars(title, _title);
        env->ReleaseStringChars(message, _message);
        return result;
    }
    

    The cast works in this case since wchar_t happen to be 16 bits wide, same as jchar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

a) I have an html page that looks like this: <html> <head> <title>Page Title</title>
I'm using valums ajax file-uploader My nodejs server side looks like this: fileStream =
I am trying to do a listview which looks like this: (source: pici.se )
I have a list of recipes obtained from a database that looks like this:
So, I have a REST application and looks like this: @GET @Produces(MediaType.APPLICATION_JSON) @Path(/getpartners) public
I'm using an entity model with metadata annotations. My controller method looks like this...
My markup looks like this : <div class='container' style='margin:10em'> <div class='content'><p>some content here !</p></div>
This is what what my screen looks like: It is composed like this :
I have some one-many normalized data that looks like this. a | x a
I've got a RewriteMap that looks like this: Guide 1 Mini-Guide 2 White Paper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.