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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:15:12+00:00 2026-06-05T16:15:12+00:00

i have imported a c++ native dll method in c#. below is how the

  • 0

i have imported a c++ native dll method in c#. below is how the c++ method look

extern "C" declspec(dllexport) int __stdcall temp(char *value)
{
  value="hksdhfs";
  return 1;
}

this how i imported in c#

[DllImport("check.dll", CallingConvention = CallingConvention.StdCall, ExactSpelling = true, EntryPoint = "temp")]
    public static extern int temp(string value);

the problem is that i am able to send the data thorough the “value” char pointer to the c++ dll, but the value is not being changed when i get “value” char pointer back in c#. Can any one please help.

  • 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-05T16:15:14+00:00Added an answer on June 5, 2026 at 4:15 pm

    As the argument is not working in this case so i changed the return type of the c++ dll method like below and getting the string in the written format

    extern "C" declspec(dllexport) char* __stdcall temp(char *value)
    {
      value="hksdhfs";
      return value;
    }
    

    and the dll import is like this

    [DllImport("check.dll", CallingConvention = CallingConvention.StdCall, ExactSpelling = true, EntryPoint = "temp")]
    [return:MarshalAs(UnmanagedType.LPStr)]
    public static extern string temp(string value);
    

    doing strcpy() will also work but if i am using the class this pointer character value to be passed that it will not work so i preferred the above way and that worked… Thanks Every one.

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

Sidebar

Related Questions

I have imported Boost library in to a .dll that I am using. I
I have imported a file using the below command code='IN' exec import %s_tmp_file %
I have imported some data into Mathematica. The data will look similar to {{0,2},{2,3},{4,3},{5,4},{8,4}}
I have imported our SVN repository into Mercurial and now we have entries for
I have imported my svn repository to git. My current branch for development is
I have imported my database by script from live site to my local server.
I have a problem with my iPhone program. I have imported a folder into
I have just imported a huge MySQL database. Most fields are latin1_swedish_ci, and they
I have a large table I imported from an Excel spreadsheet. For five of
i have downloaded whole database from geonames.org and imported all countries into mysql. i

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.