Solved

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

Posted on 2006-06-30
8
269 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

749 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