Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-28-2011, 02:34 PM
Donovan Donovan is offline
Senior Member
 
Join Date: Jan 2011
Posts: 150
Send a message via Skype™ to Donovan
Exclamation Convert ansi to unicode

Hi there

I am calling a function from a dll that returns a string.

The problem is that the dll was compiled in delphi 7 and I use delphi 2010 so the string formats are different.

The function executes correctly and I get the result when I convert the string using PChar, but I end up with an 'invalid pointer operation' afterwards.

I think what needs to happen is i need to convert the string format from ANSI to Unicode but I cannot seem to figure out how to do that, does anyone have any ideas??

Any help would be appreciated.

Thanks in advance

Donovan
Reply With Quote
  #2  
Old 04-28-2011, 03:30 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

AnsiString/PAnsiChar ?
Reply With Quote
  #3  
Old 04-28-2011, 03:56 PM
Donovan Donovan is offline
Senior Member
 
Join Date: Jan 2011
Posts: 150
Send a message via Skype™ to Donovan
Default

I did try that and I got a similar result

Do I have to create a memory buffer in order to use this?
Reply With Quote
  #4  
Old 04-29-2011, 03:56 AM
SilverBoy SilverBoy is offline
Member
 
Join Date: Jun 2010
Posts: 46
Default

Select "Project" and then "View Source" , add "ShareMem" unit to uses of your project , remember that "ShareMem" must be the first unit uses in project .

Delphi note this on start creating a DLL :

Code:
{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }
Note : the dll that written in delphi 7 must use this unit ( ShareMem ) for first library that added to uses list .
Reply With Quote
  #5  
Old 04-29-2011, 08:24 AM
Donovan Donovan is offline
Senior Member
 
Join Date: Jan 2011
Posts: 150
Send a message via Skype™ to Donovan
Default

Hi There

I use FastShareMem, do you think this could be the problem?
Reply With Quote
Reply

Tags
ansi, dll, unicode

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.