M
Mike Behrendt
Hey @all!
option explicit on
Private Declare Function GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String) As Long
Private Const MAX_COMPUTERNAME_LENGTH = 15
Sub Demo_GetComputerName()
Dim strBuffer As String
Dim lngResult As Long
lngResult = GetComputerName(strBuffer)
If lngResult = 1 Then
MsgBox(strBuffer)
End If
End Sub
gives me under .net 2 (VB 2005 Express) in row
lngResult=GetComputername(strbuffer) a
"System.AccessViolationException"-error (access on saved memory).
(translated by me from german version)
Code is nearby 1:1 from Internet-tutorials.
Where is the error?
greets,
Mike.
option explicit on
Private Declare Function GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String) As Long
Private Const MAX_COMPUTERNAME_LENGTH = 15
Sub Demo_GetComputerName()
Dim strBuffer As String
Dim lngResult As Long
lngResult = GetComputerName(strBuffer)
If lngResult = 1 Then
MsgBox(strBuffer)
End If
End Sub
gives me under .net 2 (VB 2005 Express) in row
lngResult=GetComputername(strbuffer) a
"System.AccessViolationException"-error (access on saved memory).
(translated by me from german version)
Code is nearby 1:1 from Internet-tutorials.
Where is the error?
greets,
Mike.