Solved

using a c++ dll in c#

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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…
Starting up a Project

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