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 8848561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:27:04+00:00 2026-06-14T12:27:04+00:00

I have a C++ DLL that exposes the following function. this function calls the

  • 0

I have a C++ DLL that exposes the following function. this function calls the callback function (GetProperty) immediately. I can not change the C++ DLL

// c++
DllExport unsigned int RegisterCallbackGetPropertyReal( bool (*GetProperty)( UINT property_identifer, float * value ) ) ; 

I have a C# application that uses com.sun.jna to access this function of the DLL. I have gotten to the point where the callback function is being called correctly from the c++ DLL but I can’t see to find a way to set the float * value

// Java 
public class main {
    public interface CBlargAPI extends Library {
        interface GetPropertyReal_t extends Callback {
            boolean invoke (int property_identifer, FloatByReference value);
        }
        int RegisterCallbackGetPropertyReal( GetPropertyReal_t getProperty ) ; 
    }

    public static void main(String[] args) throws Exception 
    {
        // Register call back functions         
        CBlargAPI.GetPropertyReal_t GetPropertyReal_fn = new CBACnetAPI.GetPropertyReal_t() {
            @Override
            public boolean invoke(int property_identifer, FloatByReference value) {
                System.out.println("GetPropertyReal_t: " )  ;
                value.setValue(97.5f); 
                return false; // [Edit] This is where the problem was. this should be `return true;` See my answer below. 
            }
        };
        CBlargAPI.INSTANCE.RegisterCallbackGetPropertyReal( GetPropertyReal_fn ) ;             
    }
}

What I would have expected is that the value should be set to 97.5f when it gets back to the c++ DLL. instead I get the default value of 0.000f

My question is:

  • How do I correctly set the a float pointer value in java with Jna?
  • 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-06-14T12:27:06+00:00Added an answer on June 14, 2026 at 12:27 pm

    This is a typo that no one else could have found. basicly if I return false on the GetPropertyReal_fn callback the default value of 0.000f would be used.

    I have edited the question to show where the error was.

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

Sidebar

Related Questions

I have a DLL written in C++ that I can not change. It has
I have a third-party (Win32) DLL, written in C, that exposes the following interface:
I have a DLL that I can use to pull the following information about
I have a unmanaged DLL that exposes a function that takes a pointer to
I have a C++ DLL that I wrote that has a single exposed function,
I have a dll that exports extern C __declspec(dllexport) int __stdcall Foo( void );
I have a .NET v2.0 Dll that exposes a few classes to COM. The
I have a WPF dll that contains a number of Window classes and exposes
I have a simple .NET dll built with VS2010 C# that exposes 2 static
I have an MFC application (using a legacy library that I can't change). When

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.