1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

return a char array from c++ dll to c#

Discussion in 'C#' started by refael_berger0, Sep 9, 2010.

  1. refael_berger0

    refael_berger0 New Member

    Joined:
    Sep 9, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Do you have any idea about how to return a char array or CString from C++ DLL function to c#?
    converting the char array or CString to a C# string is even better.
    thank you
     
  2. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    I think the best thing would be to export a C function from the DLL which takes a c# StringBuilder as a parameter.
    e.g:-
    Code:
    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
    
     
  3. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    9
    Trophy Points:
    0
    If you can let us know which C++ function are you using in C#?
     

Share This Page