Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Invoke a Sub or Function indirectly using a pointer to a binary exported function or a sub, usually from an external DLL.

 

Syntax

 

CALLDWORD PtrToSubOrFunction USING abc([arguments])
 

Returns

 

None

 

Parameters

 

Name

Type

Optional

Meaning

PtrToSubOrFunction

Number

No

Numeric expression containing the pointer to a

abc...


No

name of a sub or function previously declared with DECLARE statement

 

Remarks

 

Restrictions

 

See also

 

DECLARE (General form)

 

Examples

 

DECLARE FUNCTION GetProcAddress         LIB "Kernel32.dll" ALIAS "GetProcAddress"       (BYVAL hModule AS DWORD, lpProcName AS ASCIIZAS LONG

DECLARE FUNCTION FreeLibrary            LIB "Kernel32.dll" ALIAS "FreeLibrary"          (BYVAL hLibModule AS DWORD) AS LONG

DECLARE FUNCTION LoadLibraryA           LIB "Kernel32.dll" ALIAS "LoadLibraryA"         (lpLibFileName AS AsciizAS DWORD

DECLARE FUNCTION LoadLibraryW           LIB "Kernel32.dll" ALIAS "LoadLibraryW"         (lpLibFileName AS AsciizAS DWORD

 

 

DECLARE FUNCTION MessageBoxW  (

                                BYVAL hWnd      AS DWORD  ,

                                byval lpText    AS Asciiz,

                                byval lpCaption AS Asciiz,

                                BYVAL dwType    AS DWORD

                              ) AS LONG

 

 

DECLARE FUNCTION MessageBoxA  (

                                BYVAL hWnd      AS DWORD ,

                                byval lpText    AS Asciiz,

                                byval lpCaption AS Asciiz,

                                BYVAL dwType    AS DWORD

                              ) AS LONG

 

 

  uses "UI"

  

  DWord hLib

  DWord hProc

 

  hLib = LoadLibraryA("User32.dll")

  IF hLib THEN

      hProc = GetProcAddress(hLib, "MessageBoxA")

      IF hProc THEN

          CALLDWORD hProc USING MessageBoxA(0, "Simple Ansi Msg from API""Win32 Rocks"%MB_OK)

      ELSE

          '---Error

      END IF

 

      FreeLibrary hLib

  Else

    '---Error

  END IF

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software