• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Does Windows 2k have a 'c:\windows\system32' folder

I wrote an app for someone with VB6 and sent it to him.  He has Windows 2k with sp4.  He is getting the following error:
File error 76
Path not found

I have XP so I can only test it with XP and it works fine.  I do reference the folder "C:\Windows\System32" in my app.  Is it possible that he is getting that error because Windows 2k doesn't have that folder.

Thanks,
Cheers!
ahammar
0
ahammar
Asked:
ahammar
  • 2
  • 2
  • 2
  • +2
4 Solutions
 
gecko_au2003Commented:
It should do, it will obviously depend on where his windows folder is because some ppl install windows in WINNT or windows or something along those lines.

One way of doing it and I am sure there are other ways would be to use the FSO ( File System Object ) to attain the system32 folder for you as apposed to hard coding it.
0
 
nffvrxqgrcfqvvcCommented:
gecko is right..

On windows 2000 it's C:\WINNT\system32\
On Windows XP it's C:\Windows\System32\

The error is probrably because you hard coded the path. You can use a couple different methods to obtain the system32 directory.

Environ$("WINDIR")

You can use API as well

GetWindowsDirectory

0
 
rockiroadsCommented:
the other experts are spot on, win2k broke the mould by going to c:\winnt
previously and after with xp, default is c:\windows
note users may also have installed windows in their own directory and not accept the default

Use the advice from egl1044, use an API, credit goes to egl1044 if u decide to use API

If u have sample code then fine, if not, then try this



Private Const MAX_PATH As Long = 260
         
Private Declare Function GetSystemDirectory Lib "kernel32" _
   Alias "GetSystemDirectoryA" _
  (ByVal lpBuffer As String, _
   ByVal nSize As Long) As Long

public Function GetSystemDir() As String

    Dim nSize As Long
    Dim buff As String
   
    buff = Space$(MAX_PATH)
    nSize = Len(buff)
    Call GetSystemDirectory(buff, nSize)
   
    GetSystemDir = TrimNull(buff)
   
End Function


Private Function TrimNull(item As String)

    Dim pos As Integer
   
   'double check that there is a chr$(0) in the string
    pos = InStr(item, Chr$(0))
    If pos Then
       TrimNull = Left$(item, pos - 1)
    Else
       TrimNull = item
    End If
 
End Function





If u call GetSystemDir, it will return u the name of the System32 folder

0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
pradapkumarCommented:
put the following line in a module

Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long


and use the follwoing snippet as you wish

    Dim strSysPath As String, i As Long
    strSysPath = Space(256)
    i = 256
    i = GetSystemDirectory(strSysPath, i)
    'Now strSysPath consists the system32 folder path.
    MsgBox Left$(strSysPath, i)


which will give you the current system path. So, Your program will be work without any error.

Thats all.
0
 
ahammarAuthor Commented:
Thank you all very very much!  I have tried and tested rockiroads's code and it works good on XP.  I assume it will work good on Win2k also but I'm still waiting to hear back from the client.  I will be back.  I'm pretty sure my problem is solved.  I will probably end up splitting points here somewhat.
Again, thank you all very much!
Cheers!
ahammar
0
 
ahammarAuthor Commented:
Thanks to all of you.  I have heard back and it seems to work fine.  You guys are life savers.  I'm not sure how to be fair, but I think I should give rockiroads the majority of points because he (she) was first with a complete answer and code, and that is what I used.  I know pradapkumer's code would have worked just as well, so I thank all of you.
rockiroads: 350
egl1044: 50
gecko_ua2003: 50
pradapkumer: 50

Cheers!
ahammar
0
 
rockiroadsCommented:
No probs and thanks for the grade
but like I said, I just gave an example from what egl1044 said
0
 
pradapkumarCommented:
THankyou.
The time delay due to testing of the code.
Its fine split and thankyou.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now