Using dll's in pb.

Just starting out? Need help? Post your questions and find answers here.
hamza
New User
New User
Posts: 5
Joined: Mon Aug 03, 2009 11:58 am
Location: Pakistan

Using dll's in pb.

Post 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.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Using dll's in pb.

Post 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
ImageThe happiness is a road...
Not a destination
hamza
New User
New User
Posts: 5
Joined: Mon Aug 03, 2009 11:58 am
Location: Pakistan

Re: Using dll's in pb.

Post 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.
Post Reply