Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7029231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:30:41+00:00 2026-05-28T00:30:41+00:00

Delphi Xe. It is given: 1.dll, in it a unit unit DllUnit; interface uses

  • 0

Delphi Xe.

It is given:

1.dll, in it a unit

unit DllUnit; interface

uses windows, sysutils;

Procedure GuPrcA(var p:PAnsiChar;const l:integer); StdCall;
Procedure GuPrcW(var p:PWideChar;const l:integer); StdCall;

Exports GuPrcA,GuPrcW;

implementation

procedure GuMes(s:string);
begin
MessageBox(0,pchar(s),'From dll',mb_iconinformation);
end;

Procedure GuPrcW(var p:PWideChar;const l:integer); // wide
var s:widestring;
begin
if (p=nil)or(l<1) then begin p:=nil;exit;end;
SetLength(s,trunc(l/sizeof(widechar)));Move(p^,Pointer(s)^,l);
gumes('l: '+inttostr(l)+', nl: '+inttostr(length(s))+#10+'-'+s+'-');
s:=widestring(Uppercase(s));Move(Pointer(s)^,p^,l);
end;

Procedure GuPrcA(var p:Pansichar;const l:integer); // ansi
var s:ansistring;
begin
if (p=nil)or(l<1) then begin p:=nil;exit;end;
SetLength(s,l);Move(p^,Pointer(s)^,l);
gumes('l: '+inttostr(l)+', nl: '+inttostr(length(s))+#10+'-'+s+'-');
s:=ansistring(AnsiUppercase(s));Move(Pointer(s)^,p^,l);
end;

Initialization

ReportMemoryLeaksOnShutdown:=true;

end.

2.The program, at a window memo and 2 buttons

...
implementation

{$R *.dfm}

Procedure GuPrcA(var p:PansiChar;const l:cardinal); StdCall; external 'mydll.dll' name 'GuPrcA';
Procedure GuPrcW(var p:PwideChar;const l:cardinal); StdCall; external 'mydll.dll' name 'GuPrcW';

procedure TForm1.Button6Click(Sender: TObject);
var p:pwidechar;c:cardinal;s:widestring;
begin
s:=widestring(memo1.Text);
c:=length(s)*sizeof(widechar);
p:=allocmem(c);
Move(Pointer(s)^,p^,c);
GuPrcW(p,c);
s:='';setlength(s,trunc(c/sizeof(widechar)));
Move(p^,Pointer(s)^,c);
Freemem(p,c);
memo1.Text:='='+s+'= l:'+inttostr(c);
end;

procedure TForm1.Button7Click(Sender: TObject);
var p:pansichar;c:cardinal;s:ansistring;
begin
s:=ansistring(memo1.text);
c:=length(s);
p:=allocmem(c);
Move(Pointer(s)^,p^,c);
GuPrcA(p,c);
s:='';setlength(s,c);
Move(p^,Pointer(s)^,c);
Freemem(p,c);
memo1.Text:='='+s+'= l:'+inttostr(c);
end;

Initialization

ReportMemoryLeaksOnShutdown:=true;

end.

To download an source code both it is possible here: http://www.multiupload.com/WSZKF8IGP1

By pressing buttons there is a transfer in dll lines (ansi or wide string), its display in msgbox dll, its processing there (idle time uppercase) and return to the program. The manager of memory is not used (fast – simple – sharemem). Both in a program and in dll are included ReportMemoryLeaksOnShutdown (display of events about memory losses) which both are silent, i.e. like all would work also lengths of lines too everywhere coincide.

That is necessary:

  1. To look, whether there are no there errors (to check up on errors)

  2. Whether it is possible to optimise or offer a way better or easier

  3. Whether it is possible to address to this DLL with such procedures from VB or C++/C# ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:30:42+00:00Added an answer on May 28, 2026 at 12:30 am

    If you do not want to use the heap manager for you transmission of data, just use WideString kind of string.

    It will be (a bit) slower, but it will allow you to change the string length on every side.

    And it will be true Unicode, so you won’t have any trouble about char set and such when using native Delphi UnicodeString under XE. You can use WideString in your code and the conversion to string will be done silently.

    It will be all managed by Windows, so even non Delphi libraries or applications (like .Net or C++) would be able to handle it directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following Delphil DLL declaration function csd_HandleData(aBuf: PChar; aLen: integer): integer; stdcall; what
In a delphi unit, I have a global record called 'Context': interface type TContext
I have a Delphi DLL that houses a form which uses a variety of
I have a simple Delphi (2007) procedure that given a TDataSet and a (sub)list
I'm building a multi-threaded windows service application in Delphi XE2 which uses ADO database
Delphi sometimes adds {$R *.res} in front of the unit path in the .dpr
Delphi 2010 reportedly supports gestures for user interaction (mouse or touch interface), primarily through
I've given the Delphi components from bsalsa.com a try. These include a mime filter
I have a Delphi DLL that contains the following types: type TStepModeType = (smSingle,
I have some delphi code which, given a list of items, calculates the total

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.