Solved

using a c++ dll in c#

Posted on 2004-04-14
5
184 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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:nrmdev
Comment Utility
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
Comment Utility
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wefewf 2 42
create an incrementing variable name AutoHotKey 5 56
wordappend challenge 8 82
What is Python programming? 3 62
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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…

763 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

12 Experts available now in Live!

Get 1:1 Help Now