Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Gaak...generic name for Windows directory

Posted on 2000-03-09
3
Medium Priority
?
150 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 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Suggested Courses

688 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