Solved

using a c++ dll in c#

Posted on 2004-04-14
5
188 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
This is an explanation of a simple data model to help parse a JSON feed
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

823 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