Solved

Gaak...generic name for Windows directory

Posted on 2000-03-09
3
139 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

746 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

13 Experts available now in Live!

Get 1:1 Help Now