Solved

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

Posted on 2006-06-30
8
270 Views
Last Modified: 2011-03-11
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
Comment
Question by:ahammar
[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
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 23

Assisted Solution

by:gecko_au2003
gecko_au2003 earned 50 total points
ID: 17016133
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
 
LVL 29

Assisted Solution

by:nffvrxqgrcfqvvc
nffvrxqgrcfqvvc earned 50 total points
ID: 17016446
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
 
LVL 65

Accepted Solution

by:
rockiroads earned 350 total points
ID: 17016521
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 9

Assisted Solution

by:pradapkumar
pradapkumar earned 50 total points
ID: 17016582
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
 
LVL 23

Author Comment

by:ahammar
ID: 17022031
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
 
LVL 23

Author Comment

by:ahammar
ID: 17022329
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 17022426
No probs and thanks for the grade
but like I said, I just gave an example from what egl1044 said
0
 
LVL 9

Expert Comment

by:pradapkumar
ID: 17024098
THankyou.
The time delay due to testing of the code.
Its fine split and thankyou.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

729 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