Page 1 of 1

Question about "pointeur"

Posted: Wed Jan 10, 2007 4:01 pm
by burnix
Hello all. I'm new (and enthousiast on using PB) and i 've some questions.

The first (the more important for now).

I've read this message : http://purebasic.hmt-forum.com/viewtopic.php?t=893 to know how pointer works.

So i've tested it and it works. But i still have a problem. On my code i've an "invalid memory access",but the message requester works.

Code: Select all

Structure Infos
  info1.s
  info2.s
EndStructure 

Procedure toto(*chaineretour.Infos,myfile.s)

OpenLibrary(0,"toto.dll") 

Handle = CallFunction( 0, "dll_handle") 

CallFunction( 0, "dll_func1",Handle, myfile) 

*chaineretour\info1 = PeekS(CallFunction( 0,"dll_info1",Handle,params1,params2,))
MessageRequester ("", *chaineretour\info1)

CallFunction( 0, "dll_close")
CloseLibrary(0)

EndProcedure ;problem on this line

toto(@echange.Infos,Fichier$)
    
Debug echange\info1

My second question was : did PB team plan to optimize a bit, the "RenderMovieFrame" function. This function works very well but it use between 40 and 50 percent of cpu use on an athlon 64 3200. It is possible to improve it.


For the rest thanks at all the PB users :wink:

i just made some rectification on the code, but always the problem.

Posted: Wed Jan 10, 2007 4:06 pm
by srod
Difficult to help without the dll.

Which line is throwing the error?

btw, your structure in the line Procedure toto(*chaineretour.mystruct,myfile.s)
doesn't match the definition!

**EDIT: a few 'pointers' :) :

i) Always check the result of OpenLibrary() in case the library couldn't be opened. Use

Code: Select all

If OpenLibrary(0,"toto.dll")
  ...blah blah
  CallFunction(...blah...)
EndIf
ii) Check the calling convention of the library. Your code above is assumning the STDCALL convention, which is fine for Windows system dll's etc. If the library "toto.dll" is a typical 'c' library then you'll probably need to use the CDECL convention. For this use CallCFunction() in place of CallFunction() etc.

Thanks

Posted: Wed Jan 10, 2007 5:18 pm
by burnix
Thanks for the response. The problem was at the end of the procedure. To test the call of the dll i use "messagerequester", that show me the right information. But on the procedure return (on the line endprocedure) i have the error. I want to retrieve in my main program all the information in a structure.

I dont think it was a probleme with the dll, because if i dont use a structure, just display info via debug or messagerequester i dont have errors.

Thanks.
--------------------- edit on 23/01/2007 ---------

Problem solved

CallFunction( 0, "dll_Close",Handle)

in place of

CallFunction( 0, "dll_Close")