Solved

Gaak...generic name for Windows directory

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access - Capture pressed key onclick 4 33
Access 2013 combo box not working 3 44
RUNRMTCMD from AS/400 12 47
VBA: copy range dynamically based on config sheet v2 3 35
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…
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 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…

810 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