One more time - sorry Clive and list members ....
Bo Victor Thomsen
GeoConsult I/S
Denmark
Declare Function GetEnvironmentVariable Lib "kernel32" Alias
"GetEnvironmentVariableA" (ByVal lpName As String, lpBuffer As
String, ByVal nSize As Integer) As Integer
' *** No Byval on lpBuffer !!!! passed to API-function by reference
Declare Sub Main
Declare Sub GetVariable
Sub GetVariable()
Dim pName As String, pBuffer As String, pSize As Integer, Ret As integer
' ******* pBuffer Dim as string
pName = "windir"
pSize = 255
' ****** Fill pBuffer with space - characters
pBuffer = Space$(255 )
Ret = GetEnvironmentVariable(pName, pBuffer, pSize)
Note left$(pBuffer,ret)
End Sub
Sub Main
Call GetVariable
End Sub
> -----Oprindelig meddelelse-----
> Fra: Clive Taylor [SMTP:[EMAIL PROTECTED]]
> Sendt: 31. marts 2000 12:37
> Til: [EMAIL PROTECTED]
> Emne: MI Why does this DLL call trash MapInfo?
>
> I'm trying to get this routine to work in MapBasic. I developed and
> tested it in VB6 where it works fine. I made the needed changes of
> syntax Note for Msgbox and Integer for Long but when I run it it
> triggers a complete trash of MapInfo. L5ROOT is one of my system
> variables.
>
> --------------------------------------------------------------------------
> ---
>
> Declare Function GetEnvironmentVariable Lib "kernel32" Alias
> "GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As
> String, ByVal nSize As Integer) As Integer
>
> Declare Sub Main
> Declare Sub GetVariable
>
> Sub GetVariable()
>
> Dim pName As String, pBuffer As String * 255, pSize As Integer, Ret As
> integer
>
> pName = "L5ROOT"
> pSize = 255
> Ret = GetEnvironmentVariable(pName, pBuffer, pSize)
>
> Note pBuffer
>
> End Sub
>
> Sub Main
>
> Call GetVariable
>
> End Sub
>
> --------------------------------------------------------------------------
> ---
>
> Any ideas?
>
> regards
> Clive Taylor
>
>
>
> ----------------------------------------------------------------------
> To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
> "unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]