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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:05:11+00:00 2026-05-18T20:05:11+00:00

I am a complete novice at pure Windows API-level functions in C and C++

  • 0

I am a complete novice at pure Windows API-level functions in C and C++ and have been experimenting recently with .NET interoperability. I have built a simple library which has successfully returned numeric values (int/float, etc.) to a .NET caller, but I am not having as much luck with strings.

I have tried a variety of different data types, but none appear to work: LPSTR, LPCSTR, LPCTSTR, and LPCWSTR. Admittedly, I haven’t tried char*. Also, once a method is set up to return a string, does it require marshalling by .NET as a specific data type, or could it be simply read straight into a System.String object? I have tried parsing into an IntPtr then casting into a string but that did not work.

  • 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-18T20:05:12+00:00Added an answer on May 18, 2026 at 8:05 pm

    Do what the Windows API does. It typically does not return pointers, it fills in buffers that you pass in.

    Managed code:

    [DllImport("YourLibrary", CharSet = CharSet.Auto)] 
    static extern Int32  SomeArbitraryFunction (
        String        input,          // string passed to API (LPCSTR) 
        StringBuilder output,         // output filled by API (LPSTR)    
        Int32         outputMaxLen    // StringBuilder.Capacity
    ); 
    

    On the C/C++ side:

    DWORD WINAPI SomeArbitraryFunction (
        LPCSTR input,
        LPSTR output,
        DWORD outputMaxLen
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a complete novice at pure Windows API-level functions in C and C++
I am a complete novice at C# (I've never used it before) and recently
I admit - I'm a complete novice when it comes to unit testing. I
What is the average time that it would take a complete novice, whose background
I'm a complete perl novice, am running a perl script using perl 5.10 and
I have a complete XML document in a string and would like a Document
We have an auto-complete list that's populated when an you send an email to
I am a complete novice to C, and during my university work I've come
I am a complete novice to Drupal and module integration. I am given a
My apologies but I am a complete novice. Hopefully a quick one for you

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.