Articles
|
News
|
Weblogs
|
Books
|
Forums
Artima Forums
|
Articles
|
Weblogs
|
Java Answers
|
News
Sponsored Link
•
C# Answers Forum
use delphi dll in c#
3
replies on
1
page.
Most recent reply
: Apr 5, 2010 11:45 AM by
Alex Kazanskiy
Welcome
Guest
Sign In
Back to Topic List
Reply to this Topic
Search Forum
Threaded View
Previous Topic
Next Topic
Flat View: This topic has
3
replies on
1
page
Erdos Andras
Posts: 1
Nickname: easoft
Registered: May, 2004
use delphi dll in c#
Posted: May 20, 2004 5:58 AM
Reply
Advertisement
Hi
I want use dll (Delphi 7) in c#
example
delphi
procedure GetNev(s:PChar);export;
begin
ShowMessage(s) ;
end;
exports GetNev;
c#
[DllImport( "project1.dll", CallingConvention = CallingConvention.StdCall, CharSet=CharSet.Unicode )]
public static extern void GetNev(string s);
GetNev("hello");
problem:
Message is: */-/_:? (not "Hello")
what is tha problem???
Thanks Erdosa
erdos.andras@eduweb.hu
Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
Re: use delphi dll in c#
Posted: Jun 4, 2004 8:13 AM
Reply
It might be that the string is double byte in C# and single in Delphi.
Another way to call Delphi code from C# is to use COM Automation. In that case you'll be using BSTRs which should also help to alleviate the double/single byte confusion.
Joe Cheng
Posts: 65
Nickname: jcheng
Registered: Oct, 2002
Re: use delphi dll in c#
Posted: Jun 8, 2004 9:05 AM
Reply
If Matt's correct about the double/single byte conversion, I think you can fix it by just changing CharSet.Unicode to CharSet.Ansi.
Alex Kazanskiy
Posts: 1
Nickname: kazanskiy
Registered: Apr, 2010
Re: use delphi dll in c#
Posted: Apr 5, 2010 11:45 AM
Reply
Delphi declaration should be
procedure GetNev(s:PChar);export;
stdcall;
Flat View: This topic has
3
replies on
1
page
Previous Topic
Next Topic
Sponsored Links
Web
Artima.com
Copyright
© 1996-2019 Artima, Inc. All Rights Reserved. -
Privacy Policy
-
Terms of Use