MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Calling functions in a DLL in Win32

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54021] Re: [mg54008] Calling functions in a DLL in Win32
  • From: Todd Gayley <tgayley at wolfram.com>
  • Date: Tue, 8 Feb 2005 05:30:56 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

At 02:12 AM 2/7/2005, Erich Neuwirth wrote:
>In VBasic to execute the mci commands of windows,
>use the following function:
>
>Private Declare Function mciExecute Lib "winmm.dll" _
>     (ByVal lpstrCommand As String) As Long
>
>which then accepts string parameters.
>
>Is there a way to write a Mathematica wrapper function to
>get the same functionality?


Erich,

.NET/Link includes exactly that functionality via its DefineDLLFunction 
command. Here is an example of how to use it:


    Needs["NETLink`"];

    mciExecute = DefineDLLFunction["mciExecute", "winmm.dll", "int", 
{"string"}];

    mciExecute["some string"]


You could even use a VB.NET-style declaration if you prefer (but note that 
Long in VB.NET is 64 bits, not 32 as in VB6, so you need to use Integer 
instead):

    mciExecute = DefineDLLFunction["mciExecute", "winmm.dll", "Integer", 
{"ByVal lpstrCommand As String"}];



Todd Gayley
Wolfram Research 


  • Prev by Date: problem with FindRoot
  • Next by Date: Re: FullSimplify and out of memory
  • Previous by thread: Re: Calling functions in a DLL in Win32
  • Next by thread: Web services feature in Mathematica v5.1