Solved

Windows folder--win95 vs. Win98???

Posted on 1998-09-10
3
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month7 days, 14 hours left to enroll

632 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