Help and Support
 

powered byLive Search

ACC: How to Find the Windows and System Paths

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:109733
Last Review:May 6, 2003
Revision:2.0
This article was previously published under Q109733

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

This article describes how to use the GetWindowsDirectory() and GetSystemDirectory() Windows API functions to return the Windows and Windows System directory paths.

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x, or the "Building Applications" manual, Chapter 3, "Introducing Access Basic," in version 2.0.

MORE INFORMATION

The following example demonstrates how to use the GetWindowsDirectory() and GetSystemDirectory() Windows API functions:

1.Create a new module with the sample code below.

NOTE: You may have some Microsoft Windows API functions defined in an existing Microsoft Access library; therefore, your declarations may be duplicates. If you receive a duplicate procedure name error message, remove or comment out the declarations statement in your code.

NOTE: In the following sample code, an underscore (_) is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.
      '**********************************
      'Declarations section of the module
      '**********************************
      Option Compare Database
      Option Explicit

      Declare Function GetWindowsDirectory% Lib "Kernel" (ByVal lpbuffer _
         As String, ByVal nsize As Integer)
      Declare Function GetSystemDirectory% Lib "Kernel" (ByVal lpbuffer _
         As String, ByVal nsize As Integer)

      'Returns the path to the Windows directory as a string.
      Function GetWinDir () As String
         Dim lpbuffer As String * 144
         Dim Length%

         Length% = GetWindowsDirectory(lpbuffer, Len(lpbuffer))
         GetWinDir = Left(lpbuffer, Length%)
      End Function

      'Returns the path to the Windows System directory as a string.
      Function GetSysDir () As String
         Dim lpbuffer As String * 144
         Dim Length%

         Length% = GetSystemDirectory(lpbuffer, Len(lpbuffer))
         GetSysDir = Left(lpbuffer, Length%)
      End Function
						
2.From the View menu, choose Immediate Window. Type the following in the Immediate window, and then press ENTER:

? GetWinDir()

The Windows directory path will be returned.
3.Type the following in the Immediate window, and then press ENTER:

? GetSysDir()

The Windows System directory path will be returned.

APPLIES TO
Microsoft Access 1.0 Standard Edition
Microsoft Access 1.1 Standard Edition
Microsoft Access 2.0 Standard Edition

Back to the top

Keywords: 
kbhowto kbprogramming KB109733

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.