Basics of Calling DLLs in MMF
Author: | vortex2
|
Submitted: | 16th November, 2002
|
Views: | 7783
| Rated: |
|
|
What are DLLs?
DLLs, or Dynamic Link Libraries, as they are called, contain functions, which can be called by your program. These functions are relevant to the DLL file that you are using, as each DLL Contains different functions. These functions usually have parameters. These parameters, are used by the function, the parameters of the function are very important, as without them, chances are the function will not work. DLL files in the click world are very similar to MMF Extensions, except a DLL in MMF is a bit less user friendly.
Calling DLLs in MMF
To use DLLs in MMF, you first need to Call DLL object available from www.3ee.com
To use DLLs, the first thing you need to know, is the function you want to call. As each DLL contains different functions and each function does a different thing. A good site of functions is: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/functions_in_alphabetical_order.asp. This site has functions listed in alphabetical order. Now, once you find a function that you like, you should see a Grey box on the very top of the page on this site. If you look at this box, it should say something like:
BOOL Beep (
DWORD dwFreq,
DWORD dwDuration
);
And then below the box it should have:
dwFreq
[in] Frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
Windows 95/98/Me: The Beep function ignores this parameter.
dwDuration
[in] Duration of the sound, in milliseconds.
Windows 95/98/Me: The Beep function ignores this parameter.
Or something similar. Now to find the DLL this function is located in, scroll to the bottom of the page, is should say something like: Library: Use Kernel32.lib. So you know that the beep function is located in the library Kernel32.dll. So now you know, that the function is beep, with the parameters of dwFreq, and dwDuration.
Now, here comes the important part . To use this function in MMF, first you need to import the call DLL object into your project. After you have done that, the first step, is the load the DLL with the function. In this case your would load “Kernel32.dll”. Once you load the DLL with the function, the next step is the set the parameters of the function. In this case the parameters are dwFreq, and dwDuration. Now to define the parameters of the function you would use arguments. Now, for this function, the parameters are both values. So, you would set the argument as a value and in the dialog box you would set the frequency that you want the beep played, and then you would select 1, for the first parameter. You would then set the duration for the second parameter. After you are done setting all the parameters, the next thing you have to do is call the function such as “ beep” and then once you have called the function the last thing to do is unload the DLL. In this case you would do this to use the beep function of the kernel32.dll object:
----
Load DLL “Kernel32.dll”
Return a value
Set Argument to (Frequency: a value from 37 to 32,767) at 1 (or the first parameter)
Set Argument to (Duration: a value in milliseconds) at 2 (or the second parameter)
Call Function “beep”
Unload DLL
---
Now, That is how you call the beep function using the call DLL object, and Kernel32.dll. Now, for full understanding of the Call DLL object, here is another example, that uses both set argument values, and set argument strings. This example is taken from the 3ee web-site.
----
Load DLL "user32.dll"
Return a value
Set argument to 0 at 1
Set argument to "text goes here" at 2
Set argument to "title" at 3
Set argument to 0 at 4
Call function "MessageBoxA"
Unload DLL
----
This creates a message box very neat. Parameter 1 is set to 0, parameter 2 is the text for the message box, parameter 3 is the title of the message box, and parameter 4 is set to 0. Returns a value, tells the object that the function returns a value.
Well, that is about all I know currently about the Call DLL object. For more information about this object, please visit the creators web-site at www.3ee.com
Well, thanks for reading, and have fun calling DLLs.
Sources:
---
www.3ee.com
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/functions_in_alphabetical_order.asp.
http://www.flipcode.com/tutorials/tut_dll01.shtml
|
|
vortex2
Registered 27/05/2002
Points 1406
|