Solved

Gaak...generic name for Windows directory

Posted on 2000-03-09
3
146 Views
Last Modified: 2012-05-04
What is the code used to grab the name of the Windows directory and use it in my program?

Rogue
0
Comment
Question by:RogueAce
[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
 
LVL 3

Accepted Solution

by:
Simon_Hendry earned 50 total points
ID: 2602969
Use this api and function

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


function GetWinDir() As String

Dim RLength As Long
Dim WinDir As String

WinDir = Space(255)
RLength = GetWindowsDirectory(WinDir, 255)

GetWinDir =  Left(WinDir, RLength)

End Function

----

0
 
LVL 14

Expert Comment

by:wsh2
ID: 2603611
Or if you have VB6 and don't want to use API calls.. use the FSO.. <smile>

Add a Reference in your project (VB Menu.. Project.. References) to "Microsoft Scripting Runtime" ie. SCRRUN.DLL and then you can use the following.. <smile>.

<----- code begin ----->

Dim fso As New FileSystemObject
Dim strFolderName As String

strFolderName = fso.GetSpecialFolder(WindowsFolder)

MsgBox strFolderName

<----- Code End ----->

Short, sweet and 100% VB.
0
 
LVL 1

Author Comment

by:RogueAce
ID: 2605376
Thanks, you guys!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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