How to make a dll for AMS in PB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    How to make a dll for AMS in PB

    ok, im not the best at this kind of thing, but here goes

    In this quick tut you will learn how to make a small simple dialog dll with PureBasic.

    ok, frist thing you need to do is open PureBasic and create a new blank project, now goto Menu>>Compiler>>Compiler Options, in the first tab "Compiler Options" find "Executable Format" and set it to shared dll and then click ok.

    now add the below code to the PB project

    Code:
      ProcedureDLL MyFunctionName()
        MessageRequester("Hello", "This is a PureBasic DLL !", 0)
      EndProcedure

    now open a blank ams project, add a button and add the below code to the buttons on click event


    Code:
    result = DLL.CallFunction("AutoPlay\\Docs\\MyDLL.dll", "MyFunctionName", "", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);

    now, i usally save the pure basic file source file in the same folder as the ams project, this just keeps the source files togeather, so save the pure basic project and then make the dll file (Menu>>Compiler>>Make Executable) save the dll to the docs folder of the ams project

    now preview the project and click the button, you should be looking at your first ams/dll dialog, if not then you did something wrong, read the above again


    now we pass some arguments to the dll

    edit your pb code to look like this

    Code:
      ProcedureDLL MyFunctionName(strTitle$,strText$)
        MessageRequester(strTitle$,strText$, 0)
      EndProcedure
    save and complie the dll

    edit your ams code to look like this

    Code:
    strTitle="Hello"
    strText="This is a PureBasic dll with arguments passed from AMS"
    result = DLL.CallFunction("AutoPlay\\Docs\\MyDLL.dll", "MyFunctionName", "\""..strTitle.."\",\""..strText.."\"", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
    now preview and click the button, see the dialog and the text, if not then you did something wrong, read the above again.


    now lets get a return from the dll

    for this we are going to change the message type to yes/no/cancel dialog so we can get differaqnt return values

    edit your purebasic code to look like this

    Code:
      ProcedureDLL MyFunctionName(strTitle$,strText$)
        Ret=MessageRequester(strTitle$,strText$, #PB_MessageRequester_YesNoCancel)
        ProcedureReturn Ret
      EndProcedure
    save and complie the dll

    add a label to the ams project and edit the code to look like this

    Code:
    strTitle="Hello"
    strText="This is a PureBasic dll with arguments passed from AMS\r\n\r\nCheck the label for the return result."
    result = DLL.CallFunction("AutoPlay\\Docs\\MyDLL.dll", "MyFunctionName", "\""..strTitle.."\",\""..strText.."\"", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
    Label.SetText("Label1", result);
    now save and preview the ams project, see how all the buttons have differant return values,


    there you have it, your first dll
    Last edited by RizlaUK; 02-01-2009, 11:34 AM.
    Embrace change in your life, you never know, it could all work out for the best
  • clueless
    Forum Member
    • Jun 2006
    • 421

    #2
    Nice tutorial :yes

    Comment

    • Esfahan
      Forum Member
      • Oct 2007
      • 233

      #3
      Hi Rizla
      I must be makes thanks to you for this tutorial.:yes
      It is very useful for me , i'm starting with this.
      I makes first dll today!
      It's very simple and small dll, but it's my favorite, because it's my first work!
      Thanks man.


      work in XP sp2 nice
      here is Dll and apz for DL:
      Attached Files

      Comment

      • RizlaUK
        Indigo Rose Customer
        • May 2006
        • 5552

        #4
        Nice Work Esfahan :yes

        cant waity to see what else you produce, keep up the good work
        Embrace change in your life, you never know, it could all work out for the best

        Comment

        • siray
          Forum Member
          • Oct 2006
          • 120

          #5
          so interesting
          i downloaded a trial version of that prog (PB), but i dunno where and how to start it

          thanks mr. dean, thanks isfahan:yes

          Comment

          • azmanar
            Indigo Rose Customer
            • Oct 2004
            • 1020

            #6
            Rizla,

            THANKS !!!!!
            Newbie Examples
            ------> AMS 7.5 : amstudio.azman.info
            ----> AMS 6 & 5: www.azman.info/ams/
            ----> FB: facebook.com/GuideToWealth

            ----> Content Development Blog: www.AZMAN.asia

            Comment

            • karimo
              Forum Member
              • Jun 2006
              • 10

              #7
              RizlaUK,
              thank you for this tutorial. :yes

              I made a small dll to show a window to user
              What code I use in this dll to save information from this window to text file…?

              Can you correct my dll please?
              Attached Files

              Comment

              • RizlaUK
                Indigo Rose Customer
                • May 2006
                • 5552

                #8
                lol, wheres the events?

                im not going to write the dll for you, unless you pay me

                i suggest you first become a custom to useing PureBasic before attempting to make a dll and at least learn the basics

                Tip: when you make your form in the visual designer, before you send toe code to PureBasic check the "include event loop" checkbox in project options, this will generate the event loop for you

                for more help with PureBasic go HERE
                Embrace change in your life, you never know, it could all work out for the best

                Comment

                • holtgrewe
                  Indigo Rose Customer
                  • Jul 2002
                  • 779

                  #9
                  great tutorial...

                  If this turns into a PureBasic Forum - I'm outta' here. LMAO.

                  Comment

                  • TimeSurfer
                    Forum Member
                    • Dec 2007
                    • 479

                    #10
                    lol holtgrewe and **** Rizla nice tutorial....how long did that take you??? Very nice addition indeed bro :yes

                    Comment

                    • Centauri Soldier
                      Indigo Rose Customer
                      • Jun 2007
                      • 1703

                      #11
                      Holy Shnaz Rizla...nice tutorial! Thanks a bunch buddy.
                      https://github.com/CentauriSoldier

                      Comment

                      • Tone
                        Forum Member
                        • Jun 2007
                        • 718

                        #12
                        Well done mate, nice tutorial - worked perfectly.
                        Thank you so much :yes

                        Comment

                        • mystica
                          No longer a forum member
                          • May 2007
                          • 1548

                          #13
                          Uhh, yeh. The old Rizla PB-DLL tutorial resurrected, eh? This one needs to be immortalized as one of the all-time classic threads. Some good stuff has evolved from this. Did you get a look at the DLL Esfahan made from this?

                          Comment

                          • Tone
                            Forum Member
                            • Jun 2007
                            • 718

                            #14
                            Originally posted by mystica View Post
                            Uhh, yeh. The old Rizla PB-DLL tutorial resurrected, eh? This one needs to be immortalized as one of the all-time classic threads. Some good stuff has evolved from this. Did you get a look at the DLL Esfahan made from this?
                            Thanks mystica - if you meant the CD Tray one i thought it was pretty but it didn't work properly.
                            Last edited by Tone; 08-24-2010, 04:40 AM.

                            Comment

                            • mystica
                              No longer a forum member
                              • May 2007
                              • 1548

                              #15
                              Yes, I did mean the CD Tray apz. It probably didn't work for you because you tried it in AMS-8. Esfahan built this example a while ago using version 7.5 and it contains a lua script with DelimitedStringFunctions that use the old table expressions. Obviously this script would have to be updated with the new syntax for it to work in version-8. But if you try it with version 7.5, you'll see it works really well.

                              Comment

                              Working...
                              X