Home |
Search |
Today's Posts |
#21
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() wrote in message ... Sorry - I should have pointed out that the "CopyMemory" problem occurs on both 32 and 64 bit Office IF running on 64-bit Windows. I'm familiar with the PtrSafe construct but I've tried adjusting the data types (LongPtr, LongLong, etc) without success. I also emailed Randy who said he'd never tried to make it work on 64-bit OS. Another source said that anything using winsock32.dll on 64 bit OS won't work reliably, but I don't know if that is true. You can get a Name from an IP using WMI but if the remote computer isn't listening on WMI the code waits a long-time before giving up, which is no good if its along list of computers, and they may not all be running Windows! I can only reiterate Randy's original works fine for me in Win10 + Excel64 the with the usual adaptations for the APIs. Without knowing what you've changed hard to suggest why yours crashes. All the APIs should be declared with PtrSafe. The gethostbyaddr function should return a LongPtr and its hAddr argument should be a LongPtr In Randy's GetHostNameFromIP function ptrHosent and hAddress should be LongPtr If you need to cater for Office 2007 or earlier you'll need to include the differences for both APIs and declared variables (in your own functions) under #IfVBA7 ptrSafe LongPtr version.. #Else original code. #End If In passing don't declare as LongLong unless you're coding exclusively for Office64 or under #Win64.Under VBA7 LongPtr is a Long in x32 and a LongLong in x64. Another tip, look for arguments in APIs starting with h (or hwnd) or include ptr. Handles and pointers are LongPtr (ie LongLong in x64) and variables that pass or return such values should be declared as LongPtr. APIs that return similar will return a LongPtr, and should be returned to appropriately declared variables. Head your module Option Explicit and do Debug / compile in both x32 and x64 In 32 bit Office Randy's original should work fine as-is even in 64bit Windows. Make sure you copy it directly from his site. All you need to do is change the two text-box references to strings. Peter T |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Hostname from IP address | Excel Worksheet Functions | |||
How do I avoid excel change absolute address to relative address | Excel Discussion (Misc queries) | |||
Converting list of IP Addresses to list of Hostname | Excel Worksheet Functions | |||
Get IP address for a remote computer based on its hostname | Excel Programming | |||
LINKING Address cells from an EXCEL spreadsheet to fill MapQuest Address Info | Excel Programming |