View Single Post
  #34   Report Post  
Posted to microsoft.public.excel.programming
Andrey G Andrey G is offline
external usenet poster
 
Posts: 7
Default IP address to Hostname in Excel

On Tuesday, November 10, 2020 at 5:24:49 PM UTC, Peter T wrote:
"Andrey G" wrote in message
On Friday, April 14, 2017 at 12:39:40 AM UTC+1,
wrote:
Agreed - thanks Randy and apologies for the confusion re Windows/Office
versions :)

Simon


Dear all,
At work, I've inherited the file that's using Randy Birch's code from
he http://vbnet.mvps.org/index.html?cod...byhostname.htm.
Recently, all machines have been up-dated to Office 64 bit and the code
stopped working.
I've tried everything from Peter T suggestions above, but, still, as soon
as the code gets to line: CopyMemory ptrName, ByVal ptrName, 4, Excel
crashes.
I feel particularly stupid, as it looks that some people in this
conversation have actually managed to adjust original code to 64 bit,
following Peter T's advice.
Any help will be greatly appreciated!

Andrey G

What were my 'suggestions above'...?

It looks like you're attempting to copy a pointer which in x64 will be an
8-bit LongLong, or a 4-bit Long in x32

Try declaring this conditional constant, either as public in a normal module
or as private in the module you call CopyMemory

#If Win64 Then
Public Const gcPtrBytes As Long = 8
#Else
Public Const gcPtrBytes As Long = 4
#End If

and
CopyMemory ptrName, ByVal ptrName, gcPtrBytes

Only a guess with not much to go on!

Peter T


Peter,
Firstly, thank you very much for a prompt reply - I was afraid that this thread might be dead.
When I said "your suggestions" I meant: 1. All APIs were declared with PtrSafe 2. Arguments in APIs starting with h (or hwnd) or include
ptr declared as LongPtr.
Unfortunately, API calls are not my strong point.
I will try to change the pointer to 8 bit, as you advised, when I get to work PC.

Cheers,
Andrey