Solved

Gaak...generic name for Windows directory

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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 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…
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…

680 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