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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:15:40+00:00 2026-05-15T11:15:40+00:00

My C++ DLL have a function like this: void func1(int& count, int* pValue); this

  • 0

My C++ DLL have a function like this:

void func1(int& count, int* pValue);

this function will determine the “count”, and put some values into the pValue int array which is the length of “count”.

how can I define my C# code? you can ignor the [DllImport …] part.

thanks,

  • 1 1 Answer
  • 1 View
  • 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-15T11:15:41+00:00Added an answer on May 15, 2026 at 11:15 am

    By ref & isn’t going to happen as far as I’ve worked out.

    MSDN has the answers you seek

    and don’t forget to export your function from C++ as extern "C"

    According to MSDN: Default marshaling for arrays on the C# side I think you want something like the following

    public static extern void func1( 
      out int count, 
      [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] int[] values );
    

    Where SizeParamIndex tells .net which argument will hold the size of the array to be marshaled.

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

Sidebar

Related Questions

I have DLL and application that will call some function in this dll. For
I have code that looks like this: extern C __declspec(dllexport) myInterface(int id, void** pFunction)
In a C dll, I have a function like this: char* GetSomeText(char* szInputText) {
I have a vc++ dll which has a funciton call like this : typedef
I have a dll with a function that takes PyObject as argument something like
I have a function definition in my VC++ Win32 DLL DEMO2_API void ProcessData(char* i_buff,
I have a dll, it exports a function... extern C int __stdcall MP_GetFactory( gmpi::IMpUnknown**
I would like to call this C++ function from my C# code: void GetArrayOfNames(char**
see i have code like #include<stdio.h> #include<pthread.h> #include<string.h> void* thread_function(void) { printf (This is
I have a .dll library which exports a function in the following format: _Java_folder1_folder2_folder3_JavaClassName_javamethodname@16

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.