help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: help

  1. #1
    Software-Dungeon Guest

    help

    Please - why is this happening to me - the code below only returns the
    WindowsDirectory - I have done this many times before - why is this
    happening now... TIA

    '///////////////////////////////////////////////////////////////////////////
    /////

    Option Explicit
    Option Compare Text

    Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
    Long


    Public Function GetWinDir() As String
    Dim strBuffer As String
    Dim lngBuffer As Long

    strBuffer = String(200, Chr$(0))
    lngBuffer = Len(strBuffer)

    GetWindowsDirectory strBuffer, lngBuffer

    GetWinDir = Left$(strBuffer, lngBuffer)

    End Function


    Private Sub Form_Load()
    Dim OpenMe As String

    OpenMe = GetWinDir
    OpenMe = OpenMe & "\readme.exe"

    ' Why does this only return the WindowsDirectory -
    MsgBox OpenMe

    End

    End Sub

    '///////////////////////////////////////////////////////////////////////////
    //////



  2. #2
    Kevin Guest

    Re: help


    That is what it is supposed to return. It should never return any other value.

    If you want the program's application directory use the App.Path
    property.


    "Software-Dungeon" <James(AT)Software-dungeon.co.uk> wrote:
    >Please - why is this happening to me - the code below only returns the
    >WindowsDirectory - I have done this many times before - why is this
    >happening now... TIA
    >
    >'///////////////////////////////////////////////////////////////////////////
    >/////
    >
    >Option Explicit
    >Option Compare Text
    >
    >Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    >"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
    >Long
    >
    >
    >Public Function GetWinDir() As String
    >Dim strBuffer As String
    >Dim lngBuffer As Long
    >
    >strBuffer = String(200, Chr$(0))
    >lngBuffer = Len(strBuffer)
    >
    >GetWindowsDirectory strBuffer, lngBuffer
    >
    >GetWinDir = Left$(strBuffer, lngBuffer)
    >
    >End Function
    >
    >
    >Private Sub Form_Load()
    >Dim OpenMe As String
    >
    >OpenMe = GetWinDir
    >OpenMe = OpenMe & "\readme.exe"
    >
    >' Why does this only return the WindowsDirectory -
    >MsgBox OpenMe
    >
    >End
    >
    >End Sub
    >
    >'///////////////////////////////////////////////////////////////////////////
    >//////
    >
    >



  3. #3
    Kevin Guest

    Re: help


    That is what it is supposed to return. It should never return any other value.

    If you want the program's application directory use the App.Path
    property.


    "Software-Dungeon" <James(AT)Software-dungeon.co.uk> wrote:
    >Please - why is this happening to me - the code below only returns the
    >WindowsDirectory - I have done this many times before - why is this
    >happening now... TIA
    >
    >'///////////////////////////////////////////////////////////////////////////
    >/////
    >
    >Option Explicit
    >Option Compare Text
    >
    >Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    >"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
    >Long
    >
    >
    >Public Function GetWinDir() As String
    >Dim strBuffer As String
    >Dim lngBuffer As Long
    >
    >strBuffer = String(200, Chr$(0))
    >lngBuffer = Len(strBuffer)
    >
    >GetWindowsDirectory strBuffer, lngBuffer
    >
    >GetWinDir = Left$(strBuffer, lngBuffer)
    >
    >End Function
    >
    >
    >Private Sub Form_Load()
    >Dim OpenMe As String
    >
    >OpenMe = GetWinDir
    >OpenMe = OpenMe & "\readme.exe"
    >
    >' Why does this only return the WindowsDirectory -
    >MsgBox OpenMe
    >
    >End
    >
    >End Sub
    >
    >'///////////////////////////////////////////////////////////////////////////
    >//////
    >
    >



  4. #4
    Software-Dungeon Guest

    Re: help

    maybe I did not explain properly - the Form Load has is trying to return the
    Windows Directory combined with a file name - see below -

    '//////////////////////////////////////////////////////////////////////////

    Private Sub Form_Load()
    Dim OpenMe As String

    OpenMe = GetWinDir
    OpenMe = OpenMe & "\readme.exe"

    ' Why does this only return the WindowsDirectory -
    MsgBox OpenMe

    End

    End Sub

    '
    ////////////////////////////////////////////////////////////////////////////
    //////


    "Kevin" <KDM@worldnet.net> wrote in message news:3a192b58$1@news.devx.com...
    >
    > That is what it is supposed to return. It should never return any other

    value.
    >
    > If you want the program's application directory use the App.Path
    > property.
    >
    >
    > "Software-Dungeon" <James(AT)Software-dungeon.co.uk> wrote:
    > >Please - why is this happening to me - the code below only returns the
    > >WindowsDirectory - I have done this many times before - why is this
    > >happening now... TIA
    > >

    >
    >'//////////////////////////////////////////////////////////////////////////

    /
    > >/////
    > >
    > >Option Explicit
    > >Option Compare Text
    > >
    > >Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    > >"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
    > >Long
    > >
    > >
    > >Public Function GetWinDir() As String
    > >Dim strBuffer As String
    > >Dim lngBuffer As Long
    > >
    > >strBuffer = String(200, Chr$(0))
    > >lngBuffer = Len(strBuffer)
    > >
    > >GetWindowsDirectory strBuffer, lngBuffer
    > >
    > >GetWinDir = Left$(strBuffer, lngBuffer)
    > >
    > >End Function
    > >
    > >
    > >Private Sub Form_Load()
    > >Dim OpenMe As String
    > >
    > >OpenMe = GetWinDir
    > >OpenMe = OpenMe & "\readme.exe"
    > >
    > >' Why does this only return the WindowsDirectory -
    > >MsgBox OpenMe
    > >
    > >End
    > >
    > >End Sub
    > >

    >
    >'//////////////////////////////////////////////////////////////////////////

    /
    > >//////
    > >
    > >

    >




  5. #5
    Software-Dungeon Guest

    Re: help

    maybe I did not explain properly - the Form Load has is trying to return the
    Windows Directory combined with a file name - see below -

    '//////////////////////////////////////////////////////////////////////////

    Private Sub Form_Load()
    Dim OpenMe As String

    OpenMe = GetWinDir
    OpenMe = OpenMe & "\readme.exe"

    ' Why does this only return the WindowsDirectory -
    MsgBox OpenMe

    End

    End Sub

    '
    ////////////////////////////////////////////////////////////////////////////
    //////


    "Kevin" <KDM@worldnet.net> wrote in message news:3a192b58$1@news.devx.com...
    >
    > That is what it is supposed to return. It should never return any other

    value.
    >
    > If you want the program's application directory use the App.Path
    > property.
    >
    >
    > "Software-Dungeon" <James(AT)Software-dungeon.co.uk> wrote:
    > >Please - why is this happening to me - the code below only returns the
    > >WindowsDirectory - I have done this many times before - why is this
    > >happening now... TIA
    > >

    >
    >'//////////////////////////////////////////////////////////////////////////

    /
    > >/////
    > >
    > >Option Explicit
    > >Option Compare Text
    > >
    > >Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    > >"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
    > >Long
    > >
    > >
    > >Public Function GetWinDir() As String
    > >Dim strBuffer As String
    > >Dim lngBuffer As Long
    > >
    > >strBuffer = String(200, Chr$(0))
    > >lngBuffer = Len(strBuffer)
    > >
    > >GetWindowsDirectory strBuffer, lngBuffer
    > >
    > >GetWinDir = Left$(strBuffer, lngBuffer)
    > >
    > >End Function
    > >
    > >
    > >Private Sub Form_Load()
    > >Dim OpenMe As String
    > >
    > >OpenMe = GetWinDir
    > >OpenMe = OpenMe & "\readme.exe"
    > >
    > >' Why does this only return the WindowsDirectory -
    > >MsgBox OpenMe
    > >
    > >End
    > >
    > >End Sub
    > >

    >
    >'//////////////////////////////////////////////////////////////////////////

    /
    > >//////
    > >
    > >

    >




  6. #6
    Dani Sardą Guest

    Re: help

    You should use the directory actual length and not the initial buffer
    length. Something like that:

    strBuffer = String(200, Chr$(0))
    lngBuffer = Len(strBuffer)

    lngDirLength = GetWindowsDirectory(strBuffer, lngBuffer)

    GetWinDir = Left$(strBuffer, lngDirLength)

    --
    Saludos,

    Dani


    "Software-Dungeon" <James(AT)Software-dungeon.co.uk> escribió en el mensaje
    news:3a192e41@news.devx.com...
    > maybe I did not explain properly - the Form Load has is trying to return

    the
    > Windows Directory combined with a file name - see below -
    >
    >

    '//////////////////////////////////////////////////////////////////////////
    >
    > Private Sub Form_Load()
    > Dim OpenMe As String
    >
    > OpenMe = GetWinDir
    > OpenMe = OpenMe & "\readme.exe"
    >
    > ' Why does this only return the WindowsDirectory -
    > MsgBox OpenMe
    >
    > End
    >
    > End Sub
    >
    > '
    >

    ////////////////////////////////////////////////////////////////////////////
    > //////
    >
    >
    > "Kevin" <KDM@worldnet.net> wrote in message

    news:3a192b58$1@news.devx.com...
    > >
    > > That is what it is supposed to return. It should never return any other

    > value.
    > >
    > > If you want the program's application directory use the App.Path
    > > property.
    > >
    > >
    > > "Software-Dungeon" <James(AT)Software-dungeon.co.uk> wrote:
    > > >Please - why is this happening to me - the code below only returns the
    > > >WindowsDirectory - I have done this many times before - why is this
    > > >happening now... TIA
    > > >

    > >

    >
    >'//////////////////////////////////////////////////////////////////////////
    > /
    > > >/////
    > > >
    > > >Option Explicit
    > > >Option Compare Text
    > > >
    > > >Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    > > >"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long)

    As
    > > >Long
    > > >
    > > >
    > > >Public Function GetWinDir() As String
    > > >Dim strBuffer As String
    > > >Dim lngBuffer As Long
    > > >
    > > >strBuffer = String(200, Chr$(0))
    > > >lngBuffer = Len(strBuffer)
    > > >
    > > >GetWindowsDirectory strBuffer, lngBuffer
    > > >
    > > >GetWinDir = Left$(strBuffer, lngBuffer)
    > > >
    > > >End Function
    > > >
    > > >
    > > >Private Sub Form_Load()
    > > >Dim OpenMe As String
    > > >
    > > >OpenMe = GetWinDir
    > > >OpenMe = OpenMe & "\readme.exe"
    > > >
    > > >' Why does this only return the WindowsDirectory -
    > > >MsgBox OpenMe
    > > >
    > > >End
    > > >
    > > >End Sub
    > > >

    > >

    >
    >'//////////////////////////////////////////////////////////////////////////
    > /
    > > >//////
    > > >
    > > >

    > >

    >
    >




  7. #7
    Dani Sardą Guest

    Re: help

    You should use the directory actual length and not the initial buffer
    length. Something like that:

    strBuffer = String(200, Chr$(0))
    lngBuffer = Len(strBuffer)

    lngDirLength = GetWindowsDirectory(strBuffer, lngBuffer)

    GetWinDir = Left$(strBuffer, lngDirLength)

    --
    Saludos,

    Dani


    "Software-Dungeon" <James(AT)Software-dungeon.co.uk> escribió en el mensaje
    news:3a192e41@news.devx.com...
    > maybe I did not explain properly - the Form Load has is trying to return

    the
    > Windows Directory combined with a file name - see below -
    >
    >

    '//////////////////////////////////////////////////////////////////////////
    >
    > Private Sub Form_Load()
    > Dim OpenMe As String
    >
    > OpenMe = GetWinDir
    > OpenMe = OpenMe & "\readme.exe"
    >
    > ' Why does this only return the WindowsDirectory -
    > MsgBox OpenMe
    >
    > End
    >
    > End Sub
    >
    > '
    >

    ////////////////////////////////////////////////////////////////////////////
    > //////
    >
    >
    > "Kevin" <KDM@worldnet.net> wrote in message

    news:3a192b58$1@news.devx.com...
    > >
    > > That is what it is supposed to return. It should never return any other

    > value.
    > >
    > > If you want the program's application directory use the App.Path
    > > property.
    > >
    > >
    > > "Software-Dungeon" <James(AT)Software-dungeon.co.uk> wrote:
    > > >Please - why is this happening to me - the code below only returns the
    > > >WindowsDirectory - I have done this many times before - why is this
    > > >happening now... TIA
    > > >

    > >

    >
    >'//////////////////////////////////////////////////////////////////////////
    > /
    > > >/////
    > > >
    > > >Option Explicit
    > > >Option Compare Text
    > > >
    > > >Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    > > >"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long)

    As
    > > >Long
    > > >
    > > >
    > > >Public Function GetWinDir() As String
    > > >Dim strBuffer As String
    > > >Dim lngBuffer As Long
    > > >
    > > >strBuffer = String(200, Chr$(0))
    > > >lngBuffer = Len(strBuffer)
    > > >
    > > >GetWindowsDirectory strBuffer, lngBuffer
    > > >
    > > >GetWinDir = Left$(strBuffer, lngBuffer)
    > > >
    > > >End Function
    > > >
    > > >
    > > >Private Sub Form_Load()
    > > >Dim OpenMe As String
    > > >
    > > >OpenMe = GetWinDir
    > > >OpenMe = OpenMe & "\readme.exe"
    > > >
    > > >' Why does this only return the WindowsDirectory -
    > > >MsgBox OpenMe
    > > >
    > > >End
    > > >
    > > >End Sub
    > > >

    > >

    >
    >'//////////////////////////////////////////////////////////////////////////
    > /
    > > >//////
    > > >
    > > >

    > >

    >
    >




  8. #8
    Software-Dungeon Guest

    Re: help

    Ahh! - thanks for pointing this out...


    "Dani Sardą" <d.sarda@NOSPAMspin.es> wrote in message
    news:3a194e53@news.devx.com...
    > You should use the directory actual length and not the initial buffer
    > length. Something like that:
    >
    > strBuffer = String(200, Chr$(0))
    > lngBuffer = Len(strBuffer)
    >
    > lngDirLength = GetWindowsDirectory(strBuffer, lngBuffer)
    >
    > GetWinDir = Left$(strBuffer, lngDirLength)
    >
    > --
    > Saludos,
    >
    > Dani
    >
    >
    > "Software-Dungeon" <James(AT)Software-dungeon.co.uk> escribió en el

    mensaje
    > news:3a192e41@news.devx.com...
    > > maybe I did not explain properly - the Form Load has is trying to return

    > the
    > > Windows Directory combined with a file name - see below -
    > >
    > >

    >

    '//////////////////////////////////////////////////////////////////////////
    > >
    > > Private Sub Form_Load()
    > > Dim OpenMe As String
    > >
    > > OpenMe = GetWinDir
    > > OpenMe = OpenMe & "\readme.exe"
    > >
    > > ' Why does this only return the WindowsDirectory -
    > > MsgBox OpenMe
    > >
    > > End
    > >
    > > End Sub
    > >
    > > '
    > >

    >

    ////////////////////////////////////////////////////////////////////////////
    > > //////
    > >
    > >
    > > "Kevin" <KDM@worldnet.net> wrote in message

    > news:3a192b58$1@news.devx.com...
    > > >
    > > > That is what it is supposed to return. It should never return any

    other
    > > value.
    > > >
    > > > If you want the program's application directory use the App.Path
    > > > property.
    > > >
    > > >
    > > > "Software-Dungeon" <James(AT)Software-dungeon.co.uk> wrote:
    > > > >Please - why is this happening to me - the code below only returns

    the
    > > > >WindowsDirectory - I have done this many times before - why is this
    > > > >happening now... TIA
    > > > >
    > > >

    > >

    >
    >'//////////////////////////////////////////////////////////////////////////
    > > /
    > > > >/////
    > > > >
    > > > >Option Explicit
    > > > >Option Compare Text
    > > > >
    > > > >Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    > > > >"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As

    Long)
    > As
    > > > >Long
    > > > >
    > > > >
    > > > >Public Function GetWinDir() As String
    > > > >Dim strBuffer As String
    > > > >Dim lngBuffer As Long
    > > > >
    > > > >strBuffer = String(200, Chr$(0))
    > > > >lngBuffer = Len(strBuffer)
    > > > >
    > > > >GetWindowsDirectory strBuffer, lngBuffer
    > > > >
    > > > >GetWinDir = Left$(strBuffer, lngBuffer)
    > > > >
    > > > >End Function
    > > > >
    > > > >
    > > > >Private Sub Form_Load()
    > > > >Dim OpenMe As String
    > > > >
    > > > >OpenMe = GetWinDir
    > > > >OpenMe = OpenMe & "\readme.exe"
    > > > >
    > > > >' Why does this only return the WindowsDirectory -
    > > > >MsgBox OpenMe
    > > > >
    > > > >End
    > > > >
    > > > >End Sub
    > > > >
    > > >

    > >

    >
    >'//////////////////////////////////////////////////////////////////////////
    > > /
    > > > >//////
    > > > >
    > > > >
    > > >

    > >
    > >

    >
    >




  9. #9
    Software-Dungeon Guest

    Re: help

    Ahh! - thanks for pointing this out...


    "Dani Sardą" <d.sarda@NOSPAMspin.es> wrote in message
    news:3a194e53@news.devx.com...
    > You should use the directory actual length and not the initial buffer
    > length. Something like that:
    >
    > strBuffer = String(200, Chr$(0))
    > lngBuffer = Len(strBuffer)
    >
    > lngDirLength = GetWindowsDirectory(strBuffer, lngBuffer)
    >
    > GetWinDir = Left$(strBuffer, lngDirLength)
    >
    > --
    > Saludos,
    >
    > Dani
    >
    >
    > "Software-Dungeon" <James(AT)Software-dungeon.co.uk> escribió en el

    mensaje
    > news:3a192e41@news.devx.com...
    > > maybe I did not explain properly - the Form Load has is trying to return

    > the
    > > Windows Directory combined with a file name - see below -
    > >
    > >

    >

    '//////////////////////////////////////////////////////////////////////////
    > >
    > > Private Sub Form_Load()
    > > Dim OpenMe As String
    > >
    > > OpenMe = GetWinDir
    > > OpenMe = OpenMe & "\readme.exe"
    > >
    > > ' Why does this only return the WindowsDirectory -
    > > MsgBox OpenMe
    > >
    > > End
    > >
    > > End Sub
    > >
    > > '
    > >

    >

    ////////////////////////////////////////////////////////////////////////////
    > > //////
    > >
    > >
    > > "Kevin" <KDM@worldnet.net> wrote in message

    > news:3a192b58$1@news.devx.com...
    > > >
    > > > That is what it is supposed to return. It should never return any

    other
    > > value.
    > > >
    > > > If you want the program's application directory use the App.Path
    > > > property.
    > > >
    > > >
    > > > "Software-Dungeon" <James(AT)Software-dungeon.co.uk> wrote:
    > > > >Please - why is this happening to me - the code below only returns

    the
    > > > >WindowsDirectory - I have done this many times before - why is this
    > > > >happening now... TIA
    > > > >
    > > >

    > >

    >
    >'//////////////////////////////////////////////////////////////////////////
    > > /
    > > > >/////
    > > > >
    > > > >Option Explicit
    > > > >Option Compare Text
    > > > >
    > > > >Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
    > > > >"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As

    Long)
    > As
    > > > >Long
    > > > >
    > > > >
    > > > >Public Function GetWinDir() As String
    > > > >Dim strBuffer As String
    > > > >Dim lngBuffer As Long
    > > > >
    > > > >strBuffer = String(200, Chr$(0))
    > > > >lngBuffer = Len(strBuffer)
    > > > >
    > > > >GetWindowsDirectory strBuffer, lngBuffer
    > > > >
    > > > >GetWinDir = Left$(strBuffer, lngBuffer)
    > > > >
    > > > >End Function
    > > > >
    > > > >
    > > > >Private Sub Form_Load()
    > > > >Dim OpenMe As String
    > > > >
    > > > >OpenMe = GetWinDir
    > > > >OpenMe = OpenMe & "\readme.exe"
    > > > >
    > > > >' Why does this only return the WindowsDirectory -
    > > > >MsgBox OpenMe
    > > > >
    > > > >End
    > > > >
    > > > >End Sub
    > > > >
    > > >

    > >

    >
    >'//////////////////////////////////////////////////////////////////////////
    > > /
    > > > >//////
    > > > >
    > > > >
    > > >

    > >
    > >

    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center