AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Class with strings in DLL

Ein Thema von WojTec · begonnen am 1. Jan 2011 · letzter Beitrag vom 7. Jan 2011
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#1

Re: Class with strings in DLL

  Alt 2. Jan 2011, 14:02
So, it's global variable in DLL project file. Initialization id done by call specified function, function fills record with data. To null it I must call next function, because DLL entry procedure seems to not work.

Delphi-Quellcode:
procedure DLLIO(dwReason: DWORD);
begin
  case dwReason of
    DLL_PROCESS_ATTACH: {...};
    DLL_PROCESS_DETACH: {...};
    end;
  end;
end;

begin
  DllProc := @DLLIO;
end.
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#2

Re: Class with strings in DLL

  Alt 7. Jan 2011, 16:58
I did it with external memory manager

But now I need use functions and classes with string parameters, I won't use memory manager, just PChar. How can I do it?
  Mit Zitat antworten Zitat
Benutzerbild von SirThornberry
SirThornberry
(Moderator)

Registriert seit: 23. Sep 2003
Ort: Bockwen
12.235 Beiträge
 
Delphi 2006 Professional
 
#3

AW: Class with strings in DLL

  Alt 7. Jan 2011, 17:08
If you use PChar and so you don't need Sharemem.
Zitat:
When I try use any function from it, raises AV
Do you have this Problem only if you have strings in your dll? I suppose you have source like this:
Delphi-Quellcode:
function GetString(): PChar;
var
  mystring: string;
begin
  mystring := 'hello world';
  result := myString;
end;
If you have such source code you will get an AV because PChar is only a Pointer (of a special type). But after leaving this funktion "mystring" is freed and so "result" points to freed memory.

It would be interesting if you get the AV during the call or later when you use the result.
Jens
Mit Source ist es wie mit Kunst - Hauptsache der Künstler versteht's
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#4

Re: Class with strings in DLL

  Alt 7. Jan 2011, 17:38
Yes, I have code like function above. So, how make it working?
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:42 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz