Page 1 of 1

Using dll's in pb.

Posted: Sat Sep 19, 2009 8:05 am
by hamza
Can anyone give me an example of loading dll in purebasic but you would be helping me if you give the source of the dll too, otherwise you would not be helping me. The example could be of any size.

Re: Using dll's in pb.

Posted: Sat Sep 19, 2009 9:25 am
by Kwai chang caine
The more simple example i can write, it's a good question for me...because i can't do more :oops:
It's just for you :wink:

Code of EXE

Code: Select all

If OpenLibrary(0, "HamzaDLL.dll")
 
 NumberOfMsgBoxHamza = 5
 Back = CallFunction(0, "FunctionOfHamza", NumberOfMsgBoxHamza)
 
 MessageRequester("Return of the DLL", "Ok...i have writen " + Str(Back) + " msgbox")
 CloseLibrary(0)
 
EndIf 
Code of DLL

Code: Select all

ProcedureDLL FunctionOfHamza(NumberOfMsgBoxHamza.l)

 For i = 1 To NumberOfMsgBoxHamza
  MessageRequester("I write Hamza", "Hello i'm Hamza and i create this msgbox " + Str(i) + " times")
 Next
 
 ProcedureReturn i - 1
 
EndProcedure

Re: Using dll's in pb.

Posted: Thu Jan 28, 2010 5:20 pm
by hamza
Kwaï chang caïne wrote:The more simple example i can write, it's a good question for me...because i can't do more :oops:
It's just for you :wink:

Code of EXE

Code: Select all

If OpenLibrary(0, "HamzaDLL.dll")
 
 NumberOfMsgBoxHamza = 5
 Back = CallFunction(0, "FunctionOfHamza", NumberOfMsgBoxHamza)
 
 MessageRequester("Return of the DLL", "Ok...i have writen " + Str(Back) + " msgbox")
 CloseLibrary(0)
 
EndIf 
Code of DLL

Code: Select all

ProcedureDLL FunctionOfHamza(NumberOfMsgBoxHamza.l)

 For i = 1 To NumberOfMsgBoxHamza
  MessageRequester("I write Hamza", "Hello i'm Hamza and i create this msgbox " + Str(i) + " times")
 Next
 
 ProcedureReturn i - 1
 
EndProcedure
First of all, i'm really sorry for late respond. http://www.purebasic.fr/english/posting ... 3&p=300125
Secondly, very very thankyou. Actually, i know how to do that, but when i create the dll in jaPBe (i don't have pure basic full version), and then when i call the function in purebasic, it returns 0.
Well man, again very very Thanks for your time.
Hey man! Please stay in contact with me, as i don't have any other friend on purebasic forums. It will be the most appriciated.
Thanks.

Your friend,
Hamza,
Asone Corp.