xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CallDll()

Executes a function located in a dynamically loaded external library.

Syntax

CallDll( <pFunction> [,<xParams,...>] ) --> xResult

Arguments

<pFunction>
This is a pointer holding the memory address of the function to execute. It is returned from function GetProcAddress().
<xParams>
The values of all following parameters specified in a comma separated list are passed on to the DLL function.

Return

The function returns the result of the called DLL function as a numeric value.

Description

CallDll() exeutes a function located in a DLL that is not created by the xHarbour compiler. It works almost like function DllCall(), but accepts a function pointer obtained by GetProcAddress(), rather than the name of the DLL file and function. The calling convention is DC_CALL_STD. Refer to function DllCall() for more information on calling external DLL functions.

Info

See also:DllCall(), DllExecuteCall(), DllPrepareCall(), FreeLibrary(), GetProcAddress(), GetLastError(), LoadLibrary()
Category: DLL functions , xHarbour extensions
Source:rtl\dllcall.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example implements a simple command line utility
// that opens a file using the associated file viewer.

   PROCEDURE Main( cFile )
      LOCAL nDll, pFunc

      IF cFile == NIL .OR. .NOT. File( cFile )
         CLS
         ? "File name must be specified"
         QUIT
      ENDIF

      nDll  := DllLoad( "Shell32.dll" )
      pFunc := GetProcAddress( nDll, "ShellExecute" )

      ? CallDll( pFunc, 0, "open", cFile, NIL, NIL, 1 )

      DllUnload( nDll )
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe