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

  • Home
  • SEARCH
  • 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 6545057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:32:25+00:00 2026-05-25T11:32:25+00:00

I have a C++ DLL that I am trying to interface with using C#.

  • 0

I have a C++ DLL that I am trying to interface with using C#. I do not have access to the DLL source code so it cannot be changed. One of the methods I need to call contains a pointer to an unsigned long:

int __stdcall Foo(FooHandle messageHandle, unsigned long* tag, char* part, char* value)

I have created a test DLL project with the same method signature so I can try to figure this out but I have not successfully been able to have the DLL change the value of the unsigned long that the pointer is referencing and get that value back on the C# side. The C# side declaration is:

[DllImport("Foo.dll", EntryPoint = "Foo", CallingConvention = CallingConvention.StdCall)]
    public static extern int Foo(int messageHandle, IntPtr tag, StringBuilder part, StringBuilder value);

When I make the call from C# and then try to convert the IntPtr to Int32 or Int64 I get a zero. I have searched on here and the net in general as well as MSDN and can’t seem to find an explaination of how to do this. I figured the char* would be the hard part but the StringBuilder just works.

How can you use a C++ DLL that changes the value of an unsigned long that is passed by pointer?

Any help would be appreciated. Thanks.

  • 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-25T11:32:25+00:00Added an answer on May 25, 2026 at 11:32 am

    Just use a uint passed by ref:

    public static extern int Foo(int messageHandle, ref uint tag, StringBuilder part, StringBuilder value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB6 dll that is trying to create a COM object using
I am trying to interface with a Dll that implements several functions, one of
I have a dll that was written in c++, I need to use this
I have a C# dll that I need to call from unmanaged C++. The
Note: All sample code is greatly simplified. I have a DLL defined as: using
I have a static S.lib that is used by my D.dll. I'm trying to
I have a VB6 Active DLL that I'm trying to call from C#. I've
So have a user interface that I wrote using MinGW QT. In the UI
I have a dll that must be useable from C etc, so I cant
I have a dll that contains a dot net assembly - common intermediate language.

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.