473,788 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.d ll", CallingConventi on =
CallingConventi on.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**********@ed uweb.hu

Nov 16 '05 #1
4 3246
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.co m

"erdosa" <er**********@e duweb-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.d ll", CallingConventi on =
CallingConventi on.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**********@ed uweb.hu

Nov 16 '05 #2
er**********@ed uweb-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/
"Programmin g 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.c om> wrote in
news:eq******** ******@TK2MSFTN GP10.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/
"Programmin g is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Nov 16 '05 #4
er**********@ed uweb-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.d ll", CallingConventi on =
CallingConventi on.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.d ll", CallingConventi on =
CallingConventi on.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.d ll", CallingConventi on =
CallingConventi on.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
3169
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 worth of it or should i continue to ude Delphi for new projects. I'am developing mostly desktop apps but in th future also ASP.NET apps. -erva
10
3176
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'; Function SearchPort (Prm1:LongWord) :LongWord; cdecl; External RFID_103_485IO name 'SearchPort';
9
5555
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 ASP.net app. We are trying to decide if it will be easier just to port some of our code over to Delphi .net or just to re-write the entire thing in C#. From what I've seen at the borland confernce the new Borland IDE looks a lot like the MS .NET...
3
2369
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 too many bugs and switch to C# and loves it. I hope to do the same. However, I have a few hurdles to jump. Firstly my boss is a Delphi nut. I have heard the guy who originally developed Delphi worked on the development of C# ? If so this maybe...
7
6500
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 number of screens to be converted are huge, we are aiming minimum regression impact. What could be the best approach? Currently the option of Delphi.Net is ruled out.
13
2078
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 came up, should we stay with Delphi and go with Delphi 2005 or not. I'm interested to here everyone's opinion. Here were a few points raised. Is the future .net and will every one have .net in 2 years time. Will Delphi be around in 5 years time....
1
8082
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 print layout for slip printers. Pass a few parameters to this method and it returns a Delphi string which contains the entire slip, ready for sending to the slip printer. Now, we're slowly migrating to .NET and am in need of printing this slip...
4
4102
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 Service. Much of the data centred functionality on the application is quite involved, and to re-write all this functionality in the .NET web service would be very time consuming. Our idea is to perhaps develop a DLL written in Delphi, which copies...
11
2913
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 processing program scankromsator in delphi because its easy to write a gui. In arabia people are using it also. Also delphi, I heard delphi allows visual programming and delphi programs run on:
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.