• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

using a c++ dll in c#

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
nrmdev
Asked:
nrmdev
  • 2
1 Solution
 
AlexFMCommented:
Is szUserPassword is [in] parameter (caller passes string to C++ function) or [out] parameter (caller supplies buffer, and C++ function fills it)?
0
 
nrmdevAuthor Commented:
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
 
Computer101Commented:
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now