Skip to content

Conversation

poiru
Copy link
Member

@poiru poiru commented Apr 11, 2025

This makes it easy to return strings in API functions like GetString. For example:

[DllExport]
public static IntPtr GetString(IntPtr data)
{
    return Rainmeter.StringBuffer.Update("hello");
}

@poiru
Copy link
Member Author

poiru commented Apr 11, 2025

cc @NSTechBytes @RicardoTM05

@poiru poiru force-pushed the poiru/add-helper branch from 58e385e to 14b269f Compare April 11, 2025 16:49
This makes it easy to return strings in API functions like `GetString`.
@poiru poiru force-pushed the poiru/add-helper branch from 14b269f to c15ded0 Compare April 11, 2025 16:55
@poiru poiru merged commit 9bcb8d3 into master Apr 11, 2025
1 check passed
@poiru poiru deleted the poiru/add-helper branch April 11, 2025 17:00
@NSTechBytes
Copy link
Contributor

This makes it easy to return strings in API functions like GetString. For example:

[DllExport]
public static IntPtr GetString(IntPtr data)
{
    return Rainmeter.StringBuffer.Update("hello");
}

Thanks for the update. I haven’t tested the new one yet, but hopefully, it’ll be easy.

@RicardoTM05
Copy link
Contributor

I tested it and works fine. It did reduce the code thus made it easier 👌

        [DllExport]
        public static IntPtr GetString(IntPtr data)
        {
            Measure measure = (Measure)GCHandle.FromIntPtr(data).Target;
            return Rainmeter.StringBuffer.Update(measure.stringReturn);
        }

@NSTechBytes
Copy link
Contributor

This makes it easy to return strings in API functions like GetString. For example:

[DllExport]
public static IntPtr GetString(IntPtr data)
{
    return Rainmeter.StringBuffer.Update("hello");
}

Is it good to add this in the manual?

@poiru
Copy link
Member Author

poiru commented Apr 12, 2025

Is it good to add this in the manual?

@NSTechBytes We already added an example to GetString, I think that might be enough. Do you think it should be mentioned somewhere else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants