Solved

How to access a char* in DLL using c#

Posted on 2009-04-07
4
221 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 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

696 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