Solved

Windows folder--win95 vs. Win98???

Posted on 1998-09-10
3
145 Views
Last Modified: 2011-10-03
I have the need to capture into a variable the path to the
Windows folder--that is, the folder where windows.exe and
.ini files are stored. I've tried this approach to get it:

     WinPath = environ("windir")

which I picked up from a help file somewhere. It works fine
when run on any PC with Windows 95, but it crashes with
the following error message when run on a Windows 98 PC:

     "Can't find project or library"

After this, VBA goes into the debug mode and highlights my
line with the environ() function. Is Windows 98 structured
significantly different from Windows 95 (I have Win95 on my
PC)? Microsoft does not seem to care about documenting
arguments usable with environ(), so I'm stuck.

Anybody know what's going on here?
0
Comment
Question by:JimKirby
3 Comments
 

Accepted Solution

by:
bjbenoit earned 100 total points
ID: 1434209
you may want to consider using the Windows API to get the informaion.

Private Declare Function GetWindowsDirectory _
  Lib "kernel32" _
  Alias "GetWindowsDirectoryA" _
  (ByVal lpBuffer As String, _
    ByVal nSize As Long) _
  As Long

0
 
LVL 2

Expert Comment

by:wj7ster
ID: 1434210
Declare this is the declaration section of a form:


Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long


Put this code somewhere in a procedure:
   
Dim sBuffer     As String
Dim lSize       As Long
Dim lRet        As Long
Dim sWinDir     As String
Dim sSysDir     As String

' * * * * * * *

    lSize = 255
    sBuffer = String$(lSize, Chr$(0))
   
    ' Get Windows Directory
    lRet = GetWindowsDirectory(sBuffer, lSize)
    sWinDir = Left$(sBuffer, lRet)
   
    ' Reset buffer
    sBuffer = String$(lSize, Chr$(0))
   
    ' Get System Directory
    lRet = GetSystemDirectory(sBuffer, lSize)
    sSysDir = Left$(sBuffer, lRet)
   
    ' You can now use the variables 'sWinDir' and 'sSysDir'


I believe that this should work under Win98 as well, although I haven't tested it under Win98.

Hope this helps...

0
 

Author Comment

by:JimKirby
ID: 1434211
The code in bjbenoit's answer works perfectly in Win95
environment. I've sent it out for testing by a friend who has
Win98, but I can't see why it shouldn't work the same there.

Now, I must progress to an understanding of the mysteries
of the Windows API and the syntax of the Declare statement.

Thank you, bjbenoit!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now