-
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
'///////////////////////////////////////////////////////////////////////////
//////
-
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
>
>'///////////////////////////////////////////////////////////////////////////
>//////
>
>
-
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
>
>'///////////////////////////////////////////////////////////////////////////
>//////
>
>
-
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
> >
>
>'//////////////////////////////////////////////////////////////////////////
/
> >//////
> >
> >
>
-
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
> >
>
>'//////////////////////////////////////////////////////////////////////////
/
> >//////
> >
> >
>
-
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
> > >
> >
>
>'//////////////////////////////////////////////////////////////////////////
> /
> > >//////
> > >
> > >
> >
>
>
-
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
> > >
> >
>
>'//////////////////////////////////////////////////////////////////////////
> /
> > >//////
> > >
> > >
> >
>
>
-
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
> > > >
> > >
> >
>
>'//////////////////////////////////////////////////////////////////////////
> > /
> > > >//////
> > > >
> > > >
> > >
> >
> >
>
>
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks