This is a discussion on How to Pass a string value from vc++ .net dll to c#? within the C and C++ Programming forums, part of the Software Development category; How to Pass a string value from vc++ .net dll to c#?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Pass a string values from VC++ dll to C#. Goals: This project is a sample for sendind string value from VC++ dll to c#. Steps: 1) copy the following code in vc++ dll project. SAMPLE_API const char * OpenFile(const char *file) { std::string sample = "test"; char *Val = new char[sample.length() + 1]; strcpy(Val, sample.c_str()); return Val; } 2) run the code and use this dll in C# 3) copy the following code in C#. [DllImport("sample.dll", EntryPoint = "OpenFile")] private static extern string OpenFile(string fileName); private void Btn_Browse_Click(object sender, EventArgs e) { string Data = OpenFile(fileName); MessageBox.Show(Data); } |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is diffrenece between string.compare and string.compareordinal | shaalini | ASP and ASP.NET Programming | 3 | 12-28-2007 10:46 PM |
| Is it possible to Pass Query String to Javascript? | velhari | HTML, CSS and Javascript Coding Techniques | 1 | 11-20-2007 10:47 PM |
| how to pass and retrieve variable(query string) in same page using ajax? | ursklakshmanan | PHP Programming | 0 | 09-17-2007 12:05 PM |
| How to pass array of string from vc++ dll to C# ? | kingmaker | C and C++ Programming | 2 | 08-10-2007 05:35 AM |
| What is the main difference between pass-by-reference and pass-by-value? | oxygen | Java Programming | 2 | 08-07-2007 01:15 AM |