Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to access a char* in DLL using c#

Posted on 2009-04-07
4
Medium Priority
?
224 Views
Last Modified: 2012-05-06
I'm using c#2008 exporess.

I have a dll contain a function
int test(char* str); written by other C languge.

I try to read the string in the function but always get error and it seems to be unsafe.
Hence, how to get the string in the function above?
Thank you.
0
Comment
Question by:xuanspider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Chris-in-Clapham earned 2000 total points
ID: 24085421
Assuming you are using DLLImport or similar construction to access the DLL then you will need to pass a StringBuilder object into the method.
0
 

Author Comment

by:xuanspider
ID: 24093195
I think I did not explain clearly. The Dll is not compiled by visio studio, is compiled by other C language "labwindow". It only supports char*, but when I using char[] to read the function. C# does not allowed me to do so no matter I use ref or out keyword.  Is there any solution?
0
 

Author Closing Comment

by:xuanspider
ID: 31567397
Solve already. I never notice that char in vs2008 is 2 byte. Thank you.
0
 
LVL 1

Expert Comment

by:Chris-in-Clapham
ID: 24094732
Do you have a code example to show what you have tried? A short piece of code and the associated error message will make it a lot clearer as to exactly what you are trying to achieve.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question