473,320 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

imort delphi dll

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: ^’rectangle’. (not "Hello")

what is tha problem???

Thanks Erdosa

er**********@eduweb.hu

Nov 16 '05 #1
4 3206
erdosa,

What is the PChar type? I am not familiar with delphi, so can you
indicate what it represents?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"erdosa" <er**********@eduweb-dot-hu.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
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: ^’rectangle’. (not "Hello")

what is tha problem???

Thanks Erdosa

er**********@eduweb.hu

Nov 16 '05 #2
er**********@eduweb-dot-hu.no-spam.invalid (erdosa) wrote in news:40acbeb5$1_
1@127.0.0.1:
I want use dll (Delphi 7) in c#
Delphi 7 is a native compiler. Do you want to use a DLL made by Delphi 7?
procedure GetNev(s:PChar);export;
Yes, it appears so...
Message is: ^’rectangle’. (not "Hello")


Your PChar is porbably not mapped in the P/Invoke correctly. Check to see how
other P/Invokes are handled with PChar. You have to marshal it IIRC since its
not a native type.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
Nov 16 '05 #3
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
news:eq**************@TK2MSFTNGP10.phx.gbl:
What is the PChar type? I am not familiar with delphi, so can you
indicate what it represents?


PChar is a Pointer to a character. CString that is. Its a pointer which
points to a list of characters terminated by a 0 byte.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Nov 16 '05 #4
er**********@eduweb-dot-hu.no-spam.invalid (erdosa) wrote in
news:40**********@127.0.0.1:
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: ^’rectangle’. (not "Hello")

what is tha problem???


Erdosa,

You should specify the stdcall calling convention on your Delphi
method. (The export directive does not need to be specified on the
method, because the "exports GetNev" does the actual exporting):

procedure GetNev(s:PChar); stdcall;

The PChar type is not UniCode. PWideChar is. Make sure the
DllImport's CharSet property matches the kind of character pointer
the Delphi method expects.

If GetNev is declared with a PChar parameter, use this DllImport
attribute:

[DllImport( "project1.dll", CallingConvention =
CallingConvention.StdCall, CharSet=CharSet.Ansi)]
public static extern void GetNev(string s);

If GetNev is declared with a PWideChar parameter, use this DllImport
attribute:

[DllImport( "project1.dll", CallingConvention =
CallingConvention.StdCall, CharSet=CharSet.Unicode)]
public static extern void GetNev(string s);
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Erva | last post by:
Hi, Is there someone who has moved from Delphi to VS.NET? I'am using Delphi currently but seriously considering to moving VS.NET. I would like to hear if someone has already done that, is it...
10
by: Arda Han | last post by:
I am migrating my some applications from Delphi to C#. But... Yes But I don't know C# professionally. I am using DLL in delphi like this : ..... const RFID_103_485IO = 'Cihaz.dll'; ...
9
by: Gclinton | last post by:
I'm looking for a comparsion of C# to Delphi .net. My company is about to begin the process of reengineering a Delphi tightly coupled win32 app and a Older Java webclient that uses JSP over to an...
3
by: lukeharpin | last post by:
Currently I have been developing applications in Delphi 7. Recently I meet up with a friend of mine who previously developed in Delphi, from version 1 - 7. When Delphi 8 .net was release he found...
7
by: Sanjay Kedare | last post by:
Hi, I am evaluating various alternatives of converting Delphi (Ver 4.0) screens to C# screens. Are there any tools available for such conversion? if yes how much conversion do they achieve? The...
13
by: lukeharpin | last post by:
Hi World, We have been developing Engineering software in Delphi 3,4,5,6,7 for a few years now. This morning we had a discussion about OOP and re-programming the software to which the question...
1
by: Thomas Due | last post by:
Hi, I manage an rather old application in which we have some fairly complex (ugly) Delphi code. This is Delphi 6 we're talking about. Among all this Delphi code there is method for formating a...
4
by: =?Utf-8?B?ZGF2ZWJ5dGhlc2Vh?= | last post by:
Dear List, We have a large application written in Delphi. I am writing a mobile app written in .NET (C#) which reads and writes into the Delphi applications Oracle database via a .NET Web...
11
by: gnuist006 | last post by:
Is there a Delphi equivalent in the C world or Scheme/LISP world ? Recently, Delphi is in resurgence. In Russia people are using like crazy. For example, Bolega has written a free image...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.