CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2006
    Posts
    55

    Red face How to get into "System32" folder?

    Hiya,

    I want to copy my files in the "c:\windows\System\" in case of Windows98 and in the "c:\windows\System32\" if it is Windows2000.

    I know there is a command verb to detect automatically the system directory (System or System32).

    Where can I get such command verbs?

  2. #2
    Join Date
    Sep 2004
    Location
    New Delhi, India
    Posts
    640

    Re: How to get into "System32" folder?

    The API for it is GetSystemDirectory. Here is its declaration:
    Code:
    Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    "I rather not play football than wear Nerrazzuri shirt" - Paolo Maldini
    FORZA MILAN!!!

  3. #3
    Join Date
    Feb 2006
    Posts
    55

    Re: How to get into "System32" folder?

    Quote Originally Posted by logan
    The API for it is GetSystemDirectory. Here is its declaration:
    Code:
    Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

    Is not there a code like %USERPROFILE% to be used in VB?
    If Yes, suggest me please with other such codes, too with usage.
    Last edited by naikosen; February 19th, 2006 at 09:03 AM.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to get into "System32" folder?

    I modified the example from www.allapi.net, so that it gets the windows and the system folders.

    Code:
    Option Explicit
    
    Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    
    Private Sub Form_Load()
        'KPD-Team 1998 - modified by dglienna
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
    
        Dim Path As String, strSave As String, strSave2 As String
        'Create a buffer string
        strSave = String(200, Chr$(0))
        strSave2 = String(200, Chr$(0))
        'Get the windows directory and append 'REGEdit.exe' to it
        MsgBox Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))
        MsgBox Left$(strSave2, GetSystemDirectory(strSave2, Len(strSave)))
    
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Sep 2004
    Location
    New Delhi, India
    Posts
    640

    Re: How to get into "System32" folder?

    Have a look at GetUserProfileDirectory. This maybe useful.
    "I rather not play football than wear Nerrazzuri shirt" - Paolo Maldini
    FORZA MILAN!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured