BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DLL: Falsche Integer Übergabe

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Philipp Heckel
Guest





PostPosted: Sun Dec 28, 2003 3:11 pm    Post subject: DLL: Falsche Integer Übergabe Reply with quote



Hi,

ich habe ein Programm, welches eine Animation in einzelnen Bildern aus
einer DLL lädt. Diese Bilder ergeben ein sich drehendes Logo.

-- Code --------- Programm ------


[..]

function Logo_GetFrameJPG(Frame: Integer): TMemoryStream; external
'MP3XL.DLL' name 'Logo_GetFrameJPG';

var Logo_Frame: integer = 0;

[..]

implementation

[..]

procedure TFMain.TLogoTimer(Sender: TObject);
var jpg: TJPEGImage;
mStream: TMemoryStream;
begin
if Logo_Frame = 59 then Logo_Frame := 0;
LSearch.Caption := inttostr(Logo_Frame); // Hier stimmt der Integerwert

try
mStream := TMemoryStream.Create;
mStream := Logo_GetFrameJPG(Integer(Logo_Frame));

jpg := TJPEGImage.Create;
jpg.LoadFromStream(mStream);

Canvas.Draw(10,10,jpg);

mStream.Free;
finally
jpg.Free;
Logo_Frame := Logo_Frame + 1;
end;
end;

-- Code --------- DLL ------

[..]

function Logo_GetFrameJPG(Frame: integer): TMemoryStream; stdcall;

implementation

{$R logo.res}

function Logo_GetFrameJPG(Frame: integer): TMemoryStream; stdcall;
var rStream: TResourceStream;
begin
try
rStream := TResourceStream.Create(HInstance, 'logo' +
inttostr(Frame), RT_RCDATA);

Result := TMemoryStream.Create;
if rStream.Size > 0 then Result.LoadFromStream(rStream);

rStream.Free;
except
Result := nil;
end;
end;

[..]

-------------------------

Beim Ausführen öffnet sich nun der Fehler:
JPEG-Fehler #42

Sicher ist, dass der Integerwert nicht richtig übergeben wird, was man
sieht, wenn man diesen speichert bzw. anzeigen lässt. Er nimmt immer den
Wert 1244704 an ?!

Wo ist da der Wurm drin?


:) Über jede Antwort dankbar.
MfG Philipp Heckel

Back to top
KLinZ
Guest





PostPosted: Sun Dec 28, 2003 10:04 pm    Post subject: Re: Falsche Integer Übergabe Reply with quote



Philipp Heckel wrote:

Quote:
ich habe ein Programm, welches eine Animation in einzelnen Bildern aus
einer DLL lädt. Diese Bilder ergeben ein sich drehendes Logo.

<snip>

Quote:
function Logo_GetFrameJPG(Frame: Integer): TMemoryStream; external
'MP3XL.DLL' name 'Logo_GetFrameJPG';

<snip>

Quote:
Sicher ist, dass der Integerwert nicht richtig übergeben wird, was man
sieht, wenn man diesen speichert bzw. anzeigen lässt. Er nimmt immer
den Wert 1244704 an ?!

You forgot to declare the prototype as 'stdcall'.

interface

function Logo_GetFrameJPG(Frame: Integer): TMemoryStream; stdcall;

implementation

function Logo_GetFrameJPG; external 'MP3XL.DLL' name 'Logo_GetFrameJPG';

--
www.zenobits.com


Back to top
VBDis
Guest





PostPosted: Wed Dec 31, 2003 11:44 am    Post subject: Re: DLL: Falsche Integer Übergabe Reply with quote



Im Artikel <bsmro4$kjf$02$1 (AT) news (DOT) t-online.com>, Philipp Heckel
<mail (AT) philsworld (DOT) de> schreibt:

Quote:
Wo ist da der Wurm drin?

Vermutlich bei "stdcall". Jede Prozedur muß im Programm und DLL immer die
gleiche Aufrufkonvention haben. Probier mal

function Logo_GetFrameJPG(Frame: Integer): TMemoryStream; external; stdcall;

oder so ähnlich.

DoDi

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.