473,325 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

how to find the system path in VB

Hi to all

I would like to store one of my file in windows system 32 folder while installing my application.Later ,when i execute my application i need check whether that particular file exist or not in the system32 folder. I want to run this in win98 and XP too,
I want to get the windows system path where the file is stored.

Please do provide the solution for the above

thanks in advance.
Jan 4 '07 #1
3 14264
sashi
1,754 Expert 1GB
Hi to all

I would like to store one of my file in windows system 32 folder while installing my application.Later ,when i execute my application i need check whether that particular file exist or not in the system32 folder. I want to run this in win98 and XP too,
I want to get the windows system path where the file is stored.

Please do provide the solution for the above

thanks in advance.
Hi there,

Kindly refer to below example code segment, hope it helps. Good luck & Take care.

Windows path
Expand|Select|Wrap|Line Numbers
  1. 'general declarations
  2.  
  3. Public Const MAX_PATH = 260
  4.  
  5. Declare Function GetWindowsDirectory Lib "kernel32" Alias _
  6. "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal _
  7. nSize As Long) As Long
  8.  
  9. 'code
  10.  
  11. Public Function GetWinPath()
  12. Dim strFolder As String
  13. Dim lngResult As Long
  14. strFolder = String(MAX_PATH, 0)
  15. lngResult = GetWindowsDirectory(strFolder, MAX_PATH)
  16. If lngResult <> 0 Then
  17.     GetWinPath = Left(strFolder, InStr(strFolder, _
  18.     Chr(0)) - 1)
  19. Else
  20.     GetWinPath = ""
  21. End If
  22. End Function
  23.  
  24. 'usage
  25.  
  26. Call MsgBox("The Windows directory is " & GetWinPath, _
  27. vbInformation)
  28.  
Windows system32 path
Expand|Select|Wrap|Line Numbers
  1. 'general declarations
  2.  
  3. Public Const MAX_PATH = 260
  4.  
  5. Declare Function GetSystemDirectory Lib "kernel32" Alias _
  6. "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal _
  7. nSize As Long) As Long
  8.  
  9. 'code
  10.  
  11. Public Function GetSystemPath()
  12. Dim strFolder As String
  13. Dim lngResult As Long
  14. strFolder = String(MAX_PATH, 0)
  15. lngResult = GetSystemDirectory(strFolder, MAX_PATH)
  16. If lngResult <> 0 Then
  17.     GetSystemPath = Left(strFolder, InStr(strFolder, _
  18.     Chr(0)) - 1)
  19. Else
  20.     GetSystemPath = ""
  21. End If
  22. End Function
  23.  
  24. 'usage
  25.  
  26. Call MsgBox("The Windows System directory is " & _
  27. GetSystemPath, vbInformation)
  28.  
Jan 4 '07 #2
Hi,
Thank you for the code,
i could get the path using winsystem32 code,for the purpose of comparing i m using filesystemobject which works smoothly.




Hi there,

Kindly refer to below example code segment, hope it helps. Good luck & Take care.

Windows path
Expand|Select|Wrap|Line Numbers
  1. 'general declarations
  2.  
  3. Public Const MAX_PATH = 260
  4.  
  5. Declare Function GetWindowsDirectory Lib "kernel32" Alias _
  6. "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal _
  7. nSize As Long) As Long
  8.  
  9. 'code
  10.  
  11. Public Function GetWinPath()
  12. Dim strFolder As String
  13. Dim lngResult As Long
  14. strFolder = String(MAX_PATH, 0)
  15. lngResult = GetWindowsDirectory(strFolder, MAX_PATH)
  16. If lngResult <> 0 Then
  17.     GetWinPath = Left(strFolder, InStr(strFolder, _
  18.     Chr(0)) - 1)
  19. Else
  20.     GetWinPath = ""
  21. End If
  22. End Function
  23.  
  24. 'usage
  25.  
  26. Call MsgBox("The Windows directory is " & GetWinPath, _
  27. vbInformation)
  28.  
Windows system32 path
Expand|Select|Wrap|Line Numbers
  1. 'general declarations
  2.  
  3. Public Const MAX_PATH = 260
  4.  
  5. Declare Function GetSystemDirectory Lib "kernel32" Alias _
  6. "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal _
  7. nSize As Long) As Long
  8.  
  9. 'code
  10.  
  11. Public Function GetSystemPath()
  12. Dim strFolder As String
  13. Dim lngResult As Long
  14. strFolder = String(MAX_PATH, 0)
  15. lngResult = GetSystemDirectory(strFolder, MAX_PATH)
  16. If lngResult <> 0 Then
  17.     GetSystemPath = Left(strFolder, InStr(strFolder, _
  18.     Chr(0)) - 1)
  19. Else
  20.     GetSystemPath = ""
  21. End If
  22. End Function
  23.  
  24. 'usage
  25.  
  26. Call MsgBox("The Windows System directory is " & _
  27. GetSystemPath, vbInformation)
  28.  
Jan 5 '07 #3
sashi
1,754 Expert 1GB
Hi,
Thank you for the code,
i could get the path using winsystem32 code,for the purpose of comparing i m using filesystemobject which works smoothly.
Hi there,

Good luck & Take care.
Jan 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: gry | last post by:
I want to write some kind of install script for my python app that will add c:\cygwin\usr\bin to the system path. I don't want to walk around to 50 PC's and twiddle through the GUI to: My...
3
by: Loi | last post by:
Hi All, I use Bulk insert to put data to myTable. When the SQL server is in local machin, it works well. But when I put the data in a sql server situated not locally, then I get a error message...
7
by: thisis | last post by:
Hi All, myGetImage.asp is suppose to create a temporary file in the client side, and display in on the client web browser. myGetImage.asp needs to know the clients web browser temporary...
0
by: drewmania001 | last post by:
When trying to setup relplication for SQL i am getting the following error. "The system cannot find the path specified" The problem is when trying to run: sp_adddistributiondb line 434:...
3
by: redefined.horizons | last post by:
I have been trying to find a way to add a directory to Python's sytem path on my MS Windows XP computer. I did some searching online, but the only solution I found involved editing the MS Windows...
1
by: NamelessNumberheadMan | last post by:
I'm having trouble reading in an xml file. My servlet retrieves the file path from the init parameters without a problem, but when I try to create a FileInputStream I get this: ...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, my problem is about services. I try comment you all steps for my issue: My development environment: Windows XP SP2
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, my problem is about services. I try comment you all steps for my issue: My development environment: Windows XP SP2
2
by: Gilles Ganault | last post by:
Hello I'm trying to use urllib to download web pages with the GET method, but Python 2.5.1 on Windows turns the URL into something funny: ======== url = "amazon.fr/search/index.php?url=search"
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.