Library tutorials & articles
Windows API
- Introduction
- Declaring Windows API
- Where are they?
- Using Windows API
- Examples
Where are they?
Standard Windows DLL's, such as Kernel32.dll and User32.dll are usually located in either the Windows directory, or the Windows System Directory. They are also sometimes installed in the same directory as your application. When you declare a Windows API function, windows will search in a number of places. The first is the Windows and System directory. If the specified DLL is not found there, then it looks in the same folder of your application. If it is not found there then it searches the current directory. You can see that windows tries very hard to find the DLL you have specified. However, if it does not find the required DLL, it will chuck up a nasty error when you first attempt to use it.
If the DLL is in none of the default locations, and you know where it is, then you can specify the path in the DLL Name parameter. In some circumstances, you will find that you do not know the location of the DLL until run time. If this is the case, there is one work around, using the fact that windows searches the current directory. You can use the following code:
'// save the current directory
strOldCurDir = CurDir$
'// change the current directory to the location of the DLL
'// in this case, the support folder, which is a sub folder of
'// the folder the application is installed in.
'// ie C:Program FilesAppNamesupport
ChDir (App.Path & "support")
'// call the DLL for the first time
lngResult = DLLName(Parameter1, Parameter2)
'// restore the current directory
ChDir (strOldCurDir)
You could write a simple function that automatically checks if the DLL has been called yet, and if not, then run the above code.
Related articles
Related discussion
-
Key_Press() event for text box
by Aquila (1 replies)
-
Regarding Visual Basic Programme
by manjunathsl2007 (0 replies)
-
how do you hide all in VB6
by CapnJack (1 replies)
-
Problem with Input File
by novavb6 (3 replies)
-
How to produce a txt file with a table??
by novavb6 (1 replies)
This thread is for discussions of Windows API.