Solved

using a c++ dll in c#

Posted on 2004-04-14
5
185 Views
Last Modified: 2010-04-17
I have a c++ dll with functions it in it use pointers. How can i use this in c#?? i cant get it to work. Below is my code

this is the c++ dll function header

BOOL LAPLSEC_GetLoginPassword(LPSTR szUserPassword)

[DllImport("LAPLSEC32.dll")]
public static extern int LAPLSEC_GetLoginName([MarshalAs(string password);

I also tried

public static extern int LAPLSEC_GetLoginName([MarshalAs(UnmanagedType.LPStr)] StringBuilder pBuffer);

I havent been able to get the string to pass properly experts please help!!!
0
Comment
Question by:nrmdev
  • 2
5 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10830693
Is szUserPassword is [in] parameter (caller passes string to C++ function) or [out] parameter (caller supplies buffer, and C++ function fills it)?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10830699
0
 

Author Comment

by:nrmdev
ID: 10830714
hi i have solved the problem

it am new to c# and dint realise a string was immuatable. so i had to use a stringbuilder to when getting input variables and override the default marshalling of the paramtere

thanks for your help alexfm

how do i close this question moderators?
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 11075393
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 127
What is Python programming? 3 103
Not needed 13 95
What are programming codes and how do they work? 7 74
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now