The following are some useful function calls to know when you're in the middle of your application, and the other API calls displayed here are pretty straightforward. Three routines—GetWindowsDirectoryA, GetSystemDirectoryA, and GetTempPathA—are called. You can pretty well see which routine performs what function just by looking at the declarations:
Declare Function wu_GetWindowsDirectory Lib "kernel32" Alias _ "GetWindowsDirectoryA" (ByVal lpBuffer As String, _ ByVal nSize As Long) As Long Declare Function wu_GetSystemDirectory Lib "kernel32" Alias _ "GetSystemDirectoryA" (ByVal lpBuffer As String, _ ByVal nSize As Long) As Long Declare Function wu_GetTempPath Lib "kernel32" Alias _ "GetTempPathA" (ByVal nBufferLength As Long, _ ByVal lpBuffer As String) As Long
As with the other examples, a form was used to display the results. You can see this form, GetDirectoriesExamples, in action in Figure 15.14.
Note
Notice that the Temp folder includes an extra backslash at the end. I believe this wasn't intended originally to follow the other two API calls. This is also obvious from the difference in the routine names. Whereas the first two have the word Directory on the end, the Temp routine has the word Path. You can use the Left() function to trim off the last backslash.
Listing 15.12 shows the code for each routine.
These routines basically follow the same pattern to set for making the API calls. You can see the way these routines are called by looking at the GetDirectoriesExamples form in Figure 15.15.
The toughest part of using API routines is figuring out which routine performs what action, especially because the routine names aren't all that descriptive. Some careful sleuthing can help you out in that regard if you look through the resources listed earlier in the section “Finding API Declarations.”
3.147.59.198