Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody

Please tell me of how can i receive a string from a native dll (written in EVC++) into a compact C# project.

Please explain with example.

Thanks in advance.
bikram singh
Posted
Updated 4-Jul-10 21:00pm
v2
Comments
Sandeep Mewara 5-Jul-10 2:59am    
Please avoid using text speak like plz.

Suppose you are going to call user32.dll function GetWindowText
following is the sample C# code
C#
//C++ function syntax ->     int GetWindowText( HWND hWnd, LPTSTR lpString, int nMaxCount );
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

//Form's button click event.
private void button1_Click(object sender, EventArgs e)
{
    const int nMaxCount = 255;
    StringBuilder str = new StringBuilder(nMaxCount);
    GetWindowText(this.Handle, str, nMaxCount);
}
 
Share this answer
 
This[^] article should get you started.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900