Beleza Galera! Tenho uma Function que captura o MACAddress Do computador e retorna como String. Na depuração ele imprime certinho, porém preciso enviar esse valor do MACAddress, via (“MSXML2.XMLHTTP”) e estou fazendo da seguinte forma…
Porém, o valor está retornando do servidor NULL , mas se eu mudar a Body com valor qualquer no parâmetro code, retorna certinho
Set objRequest = CreateObject(“MSXML2.XMLHTTP”)
strUrl = “https://exemplo.com/RecebeoMac.php”
binAsync = False
Dim Body As String
Dim MacAddress As String
MacAddress = UUID.GetMyMACAddress
Body = "{""code"":" & UUID.GetMyMACAddress & "}"
'Debug.Print UUID.GetMyMACAddress
With objRequest
.Open "POST", strUrl, binAsync
.setRequestHeader "Content-Type", "application/json"
.send (Body)
While objRequest.readyState <> 4
DoEvents
Wend
strResponse = .responseText
End With
Debug.Print strResponse
FUNÇÃO MAC ADDRRESS::
Function GetMyMACAddress() As String
'Declaring the necessary variables.
Dim strComputer As String
Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Dim myMACAddress As String
'Set the computer.
strComputer = "."
'The root\cimv2 namespace is used to access the Win32_NetworkAdapterConfiguration class.
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'A select query is used to get a collection of network adapters that have the property IPEnabled equal to true.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
'Loop through all the collection of adapters and return the MAC address of the first adapter that has a non-empty IP.
For Each objItem In colItems
If Not IsNull(objItem.IPAddress) Then myMACAddress = objItem.MacAddress
Exit For
Next
'Return the IP string.
GetMyMACAddress = CStr(myMACAddress)
End Function