View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Med Tom Med is offline
external usenet poster
 
Posts: 27
Default Excel coredumps with each call to a dll - for function RegQueryValueExA in advapi32.dll

Thanks, the variable from the registry was academic, I just took that
one from an example in c# that I knew worked. I thought if I gave the
example of the application specific value I actually needed it might
just confuse people in my post.


On 18 Sep, 21:58, "Chip Pearson" wrote:
You can use the GetComputerName API:

Public Declare Function GetComputerName Lib "kernel32" Alias
"GetComputerNameA" ( _
ByVal lpBuffer As String, _
nSize As Long) As Long

Sub AAA()
Dim CompName As String
Dim N As Long
Dim R As Long
N = 255
CompName = String$(N, vbNullChar)
R = GetComputerName(CompName, N)
If R Then
CompName = Left(CompName, N)
End If
Debug.Print CompName
End Sub

or even use Environ:

Sub BBB()
Debug.Print Environ("ComputerName")
End Sub

This is much simpler than jumping through the hoops of the registry.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consultingwww.cpearson.com
(email on the web site)

"Tom Med" wrote in message

oups.com...

On 18 Sep, 19:49, Tom Med wrote:
On 18 Sep, 19:39, Tom Med wrote: