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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:55:41+00:00 2026-06-09T00:55:41+00:00

I am trying to write a wrapper in C# for an unmanaged C/C++ dll

  • 0

I am trying to write a wrapper in C# for an unmanaged C/C++ dll I need to work with. In the process I am tring to kick the rust off of my very old C++ skills. In the .h file I see the code below.

png_demand_record_create(const char *name, const char* loc, int date, int quantity);

The first two parameters are srings and the second two are integers….right? I seem to remember in c there really is not a string but an array of characters, or the like. Isn’t *name the pointer to the character array? Why in the second parameter is the * after the “r” in char and not before the “l’ in loc??? Waht is the difference between those two parameters? Could it just by the typing of the author and it really does not matter?

Also, I am using a tool (Pinvoker) to help me write the C# wrapper for the call to the unmanaged dll (all I have is the .h file and the compiled dll). The tool gives me the following:

[DllImport(@"C:\Some.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
    public extern static png_demand_record_t png_demand_record_create([MarshalAs UnmanagedType.LPStr)] string name,
[MarshalAs(UnmanagedType.LPStr)] string loc, 
int date,
int quantity);

Looks to me as if the tool defines “name” and “loc” the same even though they are different in the .h file. Do I need to worry about this?

Thanks a ton!

  • 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-09T00:55:43+00:00Added an answer on June 9, 2026 at 12:55 am

    To answer your first question: They are exactly the same. char* str is the same as char *str is the same as char*str is the same as char * str, etc.

    As for the C#, I’m afraid I can’t be of much help there.

    If you’re interested, or if it’s relevent, here‘s the wikipedia page on c-strings (which is what you’re dealing with here).

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

Sidebar

Related Questions

I'm trying to write a wrapper dll in C++/CLI to use some native classes
I am trying to write a wrapper library for MIDI functions in WinMM.dll, but
I'm trying to write a wrapper around Android's AdbWinApi.dll. I've run dumpbin on the
I have a unmanaged third party library (C). I'm trying to write a wrapper
I'm trying to write a wrapper around Image_Graph bar charts. I actually wrote the
I'm trying to write a wrapper for Winamp input plugins and have hit a
I'm trying to write a Go wrapper using CGo for ENet . When I
I'm trying to write a SWIG wrapper for a C library that uses pointers
I am trying to write a simple wrapper around a connection pointer that will
I am trying to write a simple wrapper around log4net for my team, but

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.