Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/09/2020 in all areas

  1. I was looking for a way to embed Windows Media Player into Autoit. I found 2 Windows Media Player UDF's but both of them seem to have used the OCX directly. The problem with using the OCX directly is that the video display size cannot be changed, and it takes the size of the video inherently. @seangriffin created the VLC GUI based on embedding the IE object into the GUI and that seems to work perfectly with Windows Media Player as well and it does not give the resize problem. I built the WMP.au3 around this concept and would like to share it with everybody. Attached is the WMP.au3 and the WMP_Example.au3 where it is used. Feedback is appreciated. This is my first UDF, so please be kind. SudeepJD WMP_Example.au3 WMP.au3
    1 point
  2. Honestly, you seem confused. What do you mean no “normal way” of putting a colorbyte string somewhere? What’s a normal way? And while were at it, what exactly do you mean by “colorbyte string”? It’s not a term of art typically used in GDI. You don’t need to “fake the handle”, you use the handle to draw your “string”. One might also think “hey maybe I should post some code”. Oh you solved it, now? Using just dead ends? And the routine doesn’t “also handle a .BMP file”, it handles a string in BMP format, which is about as close a thing to a “colorbyte string” as you are gonna get. That’s why it was recommended in the first place. Wait, is it solved or not? Like I said, you seem confused.
    1 point
  3. Musashi

    File checksum

    You are right, I should have mentioned this variant too. @FrancoDM : Some time ago I created a small comparison program (only for myself), but it should help you as well . #include <Crypt.au3> #include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $sFile = @SystemDir & '\mspaint.exe' ; <== example Global $hTimer, $iTimer, $sData ConsoleWrite('----------------------------------------------------------- ' & @CRLF) ; CRC32 von trancexx : $hTimer = TimerInit() $sData = _CRC32ForFile($sFile) $iTimer = TimerDiff($hTimer) ConsoleWrite(' CRC32 - trancexx : ' & $sData & @CRLF) ConsoleWrite(' >>> Time = ' & $iTimer & " ms" & @CRLF) ConsoleWrite('----------------------------------------------------------- ' & @CRLF) ; MD5 von trancexx : $hTimer = TimerInit() $sData = _MD5ForFile($sFile) $iTimer = TimerDiff($hTimer) ConsoleWrite(' MD5 - trancexx : ' & Hex($sData) & @CRLF) ConsoleWrite(' >>> Time = ' & $iTimer & " ms" & @CRLF) ConsoleWrite('----------------------------------------------------------- ' & @CRLF) ; MD5 mit Standard AutoIt Crypt.au3 : _Crypt_Startup() $hTimer = TimerInit() $sData = _Crypt_HashFile($sFile, $CALG_MD5) $iTimer = TimerDiff($hTimer) ConsoleWrite(' MD5 - _Crypt.au3 : ' & Hex($sData) & @CRLF) ConsoleWrite(' >>> Time = ' & $iTimer & " ms" & @CRLF) ConsoleWrite('----------------------------------------------------------- ' & @CRLF) _Crypt_Shutdown() ;------------------------------------------------------------------------ ; #FUNCTION# ;=============================================================================== ; Name...........: _CRC32ForFile ; Description ...: Calculates CRC32 value for the specific file. ; Syntax.........: _CRC32ForFile ($sFile) ; Parameters ....: $sFile - Full path to the file to process. ; Return values .: Success - Returns CRC32 value in form of hex string ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - CreateFile function or call to it failed. ; |2 - CreateFileMapping function or call to it failed. ; |3 - MapViewOfFile function or call to it failed. ; |4 - RtlComputeCrc32 function or call to it failed. ; Author ........: trancexx ;========================================================================================== Func _CRC32ForFile($sFile) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _ "wstr", $sFile, _ "dword", 0x80000000, _ ; GENERIC_READ "dword", 3, _ ; FILE_SHARE_READ|FILE_SHARE_WRITE "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ ; SECURITY_ANONYMOUS "ptr", 0) If @error Or $a_hCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "CreateFileMappingW", _ "hwnd", $hFile, _ "dword", 0, _ ; default security descriptor "dword", 2, _ ; PAGE_READONLY "dword", 0, _ "dword", 0, _ "ptr", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return SetError(2, 0, "") EndIf DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Local $hFileMappingObject = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "MapViewOfFile", _ "hwnd", $hFileMappingObject, _ "dword", 4, _ ; FILE_MAP_READ "dword", 0, _ "dword", 0, _ "dword", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(3, 0, "") EndIf Local $pFile = $a_hCall[0] Local $iBufferSize = FileGetSize($sFile) Local $a_iCall = DllCall("ntdll.dll", "dword", "RtlComputeCrc32", _ "dword", 0, _ "ptr", $pFile, _ "int", $iBufferSize) If @error Or Not $a_iCall[0] Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(4, 0, "") EndIf DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Local $iCRC32 = $a_iCall[0] Return SetError(0, 0, Hex($iCRC32)) EndFunc ;==>_CRC32ForFile ; #FUNCTION# ;=============================================================================== ; Name...........: _MD5ForFile ; Description ...: Calculates MD5 value for the specific file. ; Syntax.........: _MD5ForFile ($sFile) ; Parameters ....: $sFile - Full path to the file to process. ; Return values .: Success - Returns MD5 value in form of binary data ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - CreateFile function or call to it failed. ; |2 - MD5Init function or call to it failed. ; |4 - ReadFile function or call to it failed. ; |5 - MD5Update function or call to it failed. ; |6 - MD5Final function or call to it failed. ; Author ........: trancexx ;========================================================================================== Func _MD5ForFile($sFile) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _ "wstr", $sFile, _ "dword", 0x80000000, _ ; GENERIC_READ "dword", 1, _ ; FILE_SHARE_READ "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ ; SECURITY_ANONYMOUS "ptr", 0) If @error Or $a_hCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $a_hCall[0] Local $tMD5_CTX = DllStructCreate("dword i[2];" & _ "dword buf[4];" & _ "ubyte in[64];" & _ "ubyte digest[16]") DllCall("advapi32.dll", "none", "MD5Init", "ptr", DllStructGetPtr($tMD5_CTX)) If @error Then _WinAPI_CloseHandle($hFile) Return SetError(2, 0, "") EndIf Local $tBuffer = DllStructCreate("byte[524288]") Local $pBuffer = DllStructGetPtr($tBuffer), $iSize Local $iReadErr = True While _WinAPI_ReadFile($hFile, $pBuffer, 524288, $iSize) And $iSize $iReadErr = False DllCall("advapi32.dll", "none", "MD5Update", _ "ptr", DllStructGetPtr($tMD5_CTX), _ "ptr", $pBuffer, _ "dword", $iSize) If @error Then _WinAPI_CloseHandle($hFile) Return SetError(5, 0, "") EndIf WEnd If $iReadErr Then _WinAPI_CloseHandle($hFile) Return SetError(4, 0, "") EndIf DllCall("advapi32.dll", "none", "MD5Final", "ptr", DllStructGetPtr($tMD5_CTX)) If @error Then _WinAPI_CloseHandle($hFile) Return SetError(6, 0, "") EndIf _WinAPI_CloseHandle($hFile) Local $sMD5 = DllStructGetData($tMD5_CTX, "digest") Return SetError(0, 0, $sMD5) EndFunc ;==>_MD5ForFile _Crypt_HashFile is probably the easiest to implement.
    1 point
  4. @jeff_poweruser yes it will support x64 compilation. Saludos
    1 point
  5. Trong

    Get Network Adapter Info

    Network Adapter Info use WMI (Windows Management Instrumentation) Features: Show information network card. Easily copy information, for copy just click on the line want to copy. Notifications connection, connection loss. Supports exporting information to file (CSV/INI format). Run: Export to file INI format: NetStatus.exe "PathFile.INI" Export to file CSV format: NetStatus.exe "PathFile.CSV" CSV Export to file CSV format: NetStatus.exe "PathFile.CSV" /CSV Export to file CSV format: NetStatus.exe "PathFile.CSV" --CSV UDF: Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $oErrorHandler = ObjEvent("AutoIt.Error", "_SkipObjectError") Func _SkipObjectError() ; Do nothing special, just check @error after suspect functions. EndFunc ;==>_SkipObjectError Global $sAdapterInfo Global Const $sNotAvailable = "N/A", $sBlankIP = "0.0.0.0", $sBlankMAC = "00:00:00:00:00:00" ConsoleWrite(_PrintAdaptersInfo() & @CRLF) ;==>_GetDataSetVar Func _PrintAdaptersInfo() If Not IsArray($sAdapterInfo) Then $sAdapterInfo = _GetListAdaptersInfo(".") Local $sIndex, $sAdapter, $sAdapterName, $sAdapterStatus, $sGetIPType, $sIP, $sSubNetIP, $sMAC, $sGetwayIP, $sGetwayMAC, $sSpeed, $sDNS1, $sDNS2, $sDNS3, $sDNS4, $sDNS5, $sDNS6, $sDNS7, $sDNS8, $sReturn If IsArray($sAdapterInfo) And $sAdapterInfo[0][0] > 0 Then For $x = 1 To $sAdapterInfo[0][0] $sIndex = $sAdapterInfo[$x][0] If ((_StringStripWSCR($sIndex) <> '') And ($sIndex <> $sNotAvailable)) Then $sReturn &= '+ Index: ' & $sIndex & @CRLF & '' $sAdapter = $sAdapterInfo[$x][1] If ((_StringStripWSCR($sAdapter) <> '') And ($sAdapter <> $sNotAvailable)) Then $sReturn &= '- Adapter: ' & $sAdapter & @CRLF & '' $sAdapterName = $sAdapterInfo[$x][2] If ((_StringStripWSCR($sAdapterName) <> '') And ($sAdapterName <> $sNotAvailable)) Then $sReturn &= '- Adapter Name: ' & $sAdapterName & @CRLF & '' $sAdapterStatus = $sAdapterInfo[$x][3] If ((_StringStripWSCR($sAdapterStatus) <> '') And ($sAdapterStatus <> $sNotAvailable)) Then $sReturn &= '- Adapter Status: ' & $sAdapterStatus & @CRLF & '' $sGetIPType = $sAdapterInfo[$x][4] If ((_StringStripWSCR($sGetIPType) <> '') And ($sGetIPType <> $sNotAvailable)) Then $sReturn &= '- IP Type: ' & $sGetIPType & @CRLF & '' $sIP = $sAdapterInfo[$x][5] If ((_StringStripWSCR($sIP) <> '') And ($sIP <> $sNotAvailable) And ($sIP <> $sBlankIP)) Then $sReturn &= '- IP: ' & $sIP & @CRLF & '' $sSubNetIP = $sAdapterInfo[$x][6] If ((_StringStripWSCR($sSubNetIP) <> '') And ($sSubNetIP <> $sNotAvailable) And ($sSubNetIP <> $sBlankIP)) Then $sReturn &= '- SubNet IP: ' & $sSubNetIP & @CRLF & '' $sMAC = $sAdapterInfo[$x][7] If ((_StringStripWSCR($sMAC) <> '') And ($sMAC <> $sNotAvailable) And ($sMAC <> $sBlankMAC)) Then $sReturn &= '- MAC: ' & $sMAC & @CRLF & '' $sGetwayIP = $sAdapterInfo[$x][8] If ((_StringStripWSCR($sGetwayIP) <> '') And ($sGetwayIP <> $sNotAvailable) And ($sGetwayIP <> $sBlankIP)) Then $sReturn &= '- Getway IP: ' & $sGetwayIP & @CRLF & '' $sGetwayMAC = $sAdapterInfo[$x][9] If ((_StringStripWSCR($sGetwayMAC) <> '') And ($sGetwayMAC <> $sNotAvailable) And ($sGetwayMAC <> $sBlankMAC)) Then $sReturn &= '- Getway MAC: ' & $sGetwayMAC & @CRLF & '' $sSpeed = $sAdapterInfo[$x][10] If ((_StringStripWSCR($sSpeed) <> '') And ($sSpeed <> $sNotAvailable)) Then $sReturn &= '- Speed: ' & $sSpeed & @CRLF & '' $sDNS1 = $sAdapterInfo[$x][11] If ((_StringStripWSCR($sDNS1) <> '') And ($sDNS1 <> $sNotAvailable) And ($sDNS1 <> $sBlankIP)) Then $sReturn &= '- DNS 1: ' & $sDNS1 & @CRLF & '' $sDNS2 = $sAdapterInfo[$x][12] If ((_StringStripWSCR($sDNS2) <> '') And ($sDNS2 <> $sNotAvailable) And ($sDNS2 <> $sBlankIP)) Then $sReturn &= '- DNS 2: ' & $sDNS2 & @CRLF & '' $sDNS3 = $sAdapterInfo[$x][13] If ((_StringStripWSCR($sDNS3) <> '') And ($sDNS3 <> $sNotAvailable) And ($sDNS3 <> $sBlankIP)) Then $sReturn &= '- DNS 3: ' & $sDNS3 & @CRLF & '' $sDNS4 = $sAdapterInfo[$x][14] If ((_StringStripWSCR($sDNS4) <> '') And ($sDNS4 <> $sNotAvailable) And ($sDNS4 <> $sBlankIP)) Then $sReturn &= '- DNS 4: ' & $sDNS4 & @CRLF & '' $sDNS5 = $sAdapterInfo[$x][15] If ((_StringStripWSCR($sDNS5) <> '') And ($sDNS5 <> $sNotAvailable) And ($sDNS5 <> $sBlankIP)) Then $sReturn &= '- DNS 5: ' & $sDNS5 & @CRLF & '' $sDNS6 = $sAdapterInfo[$x][16] If ((_StringStripWSCR($sDNS6) <> '') And ($sDNS6 <> $sNotAvailable) And ($sDNS6 <> $sBlankIP)) Then $sReturn &= '- DNS 6: ' & $sDNS6 & @CRLF & '' $sDNS7 = $sAdapterInfo[$x][17] If ((_StringStripWSCR($sDNS7) <> '') And ($sDNS7 <> $sNotAvailable) And ($sDNS7 <> $sBlankIP)) Then $sReturn &= '- DNS 7: ' & $sDNS7 & @CRLF & '' $sDNS8 = $sAdapterInfo[$x][18] If ((_StringStripWSCR($sDNS8) <> '') And ($sDNS8 <> $sNotAvailable) And ($sDNS8 <> $sBlankIP)) Then $sReturn &= '- DNS 8: ' & $sDNS8 & @CRLF & '' $sReturn &= @CRLF & '' Next Return $sReturn Else Return SetError(1, 0, '') EndIf EndFunc ;==>_PrintAdaptersInfo Func _StringStripWSCR($iString = '') $iString = StringStripCR($iString) $iString = StringStripWS($iString, 8) Return $iString EndFunc ;==>_StringStripWSCR ;==>_GetListAdaptersInfo Func _GetListAdaptersInfo($sComputer = ".") Local $Cols = 20, $strIndex, $objVAR, $objVARx, $zAdapter, $zAdapterName, $zSpeed, $zIndex, $zInterfaceIndex, $zGetIPType, $zAdapterStatus, $zIP, $zMAC, $zSubNetIP, $zGetwayIP, $zGetwayMAC Local $aReturn[1][$Cols] = [[0, $Cols]] If $sComputer = Default Then $sComputer = @ComputerName Local $sListIndexInterfaceName = _ListIndexInterfaceName() Local $objWMI = ObjGet("winmgmts:\\" & $sComputer & "\root\cimv2") Local $objWQLx = $objWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID != NULL", "WQL", 0x30) ;~ Local $objWQLx = $objWMI.ExecQuery('Select * From Win32_NetworkAdapter', "WQL", 0x30) If Not @error And IsObj($objWQLx) Then For $objVARx In $objWQLx $zAdapterName = $objVARx.NetConnectionID If (_StringStripWSCR($zAdapterName) = "") Then ContinueLoop $zSpeed = _ByteSuffixRound($objVARx.Speed) ; Vista+ If Int($zSpeed) <= 0 Then For $z = 0 To UBound($sListIndexInterfaceName) - 1 If $sListIndexInterfaceName[$z][1] = $zAdapterName Then $zSpeed = _ByteSuffixRound(InterfaceIndexSpeed($sListIndexInterfaceName[$z][0])) Next EndIf $zAdapterStatus = $objVARx.NetConnectionStatus Switch $zAdapterStatus Case 0, 3 $zAdapterStatus = "Disable" Case 1, 2 $zAdapterStatus = "Connected" Case $zAdapterStatus = 7 $zAdapterStatus = "unPlugged" Case Else $zAdapterStatus = $sNotAvailable EndSwitch $strIndex = $objVARx.Index Local $objWQL = $objWMI.ExecQuery('SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index=' & $strIndex, "WQL", 0x30) If Not @error And IsObj($objWQL) Then For $objVAR In $objWQL $zAdapter = $objVAR.Description $aReturn[0][0] += 1 $zIndex = $aReturn[0][0] ReDim $aReturn[$zIndex * 2][$aReturn[0][1]] $zInterfaceIndex = $objVAR.InterfaceIndex If Int($zInterfaceIndex) <= 0 Then For $z = 0 To UBound($sListIndexInterfaceName) - 1 If $sListIndexInterfaceName[$z][1] = $zAdapterName Then $zInterfaceIndex = $sListIndexInterfaceName[$z][0] Next EndIf $aReturn[$zIndex][0] = $zInterfaceIndex $aReturn[$zIndex][1] = $zAdapter $aReturn[$zIndex][2] = $zAdapterName $aReturn[$zIndex][3] = $zAdapterStatus $zGetIPType = $objVAR.DHCPEnabled If $zGetIPType Then $zGetIPType = "DHCP" Else $zGetIPType = "StaticIP" EndIf $aReturn[$zIndex][4] = $zGetIPType $zIP = $objVAR.IPAddress(0) If _StringStripWSCR($zIP) = "" Then $zIP = $sNotAvailable $aReturn[$zIndex][5] = $zIP $zSubNetIP = $objVAR.IPSubnet(0) If _StringStripWSCR($zSubNetIP) = "" Then $zSubNetIP = $sNotAvailable $aReturn[$zIndex][6] = $zSubNetIP $zMAC = $objVAR.MACAddress If _StringStripWSCR($zMAC) = "" Then $zMAC = $sNotAvailable $aReturn[$zIndex][7] = $zMAC $zGetwayIP = $objVAR.DefaultIPGateway(0) If _StringStripWSCR($zGetwayIP) = "" Then $zGetwayIP = $sNotAvailable $aReturn[$zIndex][8] = $zGetwayIP $zGetwayMAC = $sNotAvailable If _StringStripWSCR($zGetwayIP) <> $sNotAvailable Then $zGetwayMAC = _GetMACFromIP($zGetwayIP) $aReturn[$zIndex][9] = $zGetwayMAC If Number($zSpeed) = 0 Then $zSpeed = $sNotAvailable $aReturn[$zIndex][10] = $zSpeed $aReturn[$zIndex][11] = $sNotAvailable $aReturn[$zIndex][12] = $sNotAvailable $aReturn[$zIndex][13] = $sNotAvailable $aReturn[$zIndex][14] = $sNotAvailable $aReturn[$zIndex][15] = $sNotAvailable $aReturn[$zIndex][16] = $sNotAvailable $aReturn[$zIndex][17] = $sNotAvailable $aReturn[$zIndex][18] = $sNotAvailable Local $zDNS = $objVAR.DNSServerSearchOrder() Local $dnsCount = UBound($zDNS) - 1 $aReturn[$zIndex][19] = $dnsCount If IsArray($zDNS) Then Switch $dnsCount Case 1 $aReturn[$zIndex][11] = $zDNS[0] Case 2 $aReturn[$zIndex][11] = $zDNS[0] $aReturn[$zIndex][12] = $zDNS[1] Case 3 $aReturn[$zIndex][11] = $zDNS[0] $aReturn[$zIndex][12] = $zDNS[1] $aReturn[$zIndex][13] = $zDNS[2] Case 4 $aReturn[$zIndex][11] = $zDNS[0] $aReturn[$zIndex][12] = $zDNS[1] $aReturn[$zIndex][13] = $zDNS[2] $aReturn[$zIndex][14] = $zDNS[3] Case 5 $aReturn[$zIndex][11] = $zDNS[0] $aReturn[$zIndex][12] = $zDNS[1] $aReturn[$zIndex][13] = $zDNS[2] $aReturn[$zIndex][14] = $zDNS[3] $aReturn[$zIndex][15] = $zDNS[4] Case 6 $aReturn[$zIndex][11] = $zDNS[0] $aReturn[$zIndex][12] = $zDNS[1] $aReturn[$zIndex][13] = $zDNS[2] $aReturn[$zIndex][14] = $zDNS[3] $aReturn[$zIndex][15] = $zDNS[4] $aReturn[$zIndex][16] = $zDNS[5] Case 7 $aReturn[$zIndex][11] = $zDNS[0] $aReturn[$zIndex][12] = $zDNS[1] $aReturn[$zIndex][13] = $zDNS[2] $aReturn[$zIndex][14] = $zDNS[3] $aReturn[$zIndex][15] = $zDNS[4] $aReturn[$zIndex][16] = $zDNS[5] $aReturn[$zIndex][17] = $zDNS[6] Case 8 $aReturn[$zIndex][11] = $zDNS[0] $aReturn[$zIndex][12] = $zDNS[1] $aReturn[$zIndex][13] = $zDNS[2] $aReturn[$zIndex][14] = $zDNS[3] $aReturn[$zIndex][15] = $zDNS[4] $aReturn[$zIndex][16] = $zDNS[5] $aReturn[$zIndex][17] = $zDNS[6] $aReturn[$zIndex][18] = $zDNS[7] Case Else $aReturn[$zIndex][11] = $zDNS[0] EndSwitch EndIf Next EndIf Next Return $aReturn EndIf Return SetError(1, 0, "") EndFunc ;==>_GetListAdaptersInfo Func _ListIndexInterfaceName() Local Const $tagIP_ADAPTER_ADDRESSES = "ulong Length;dword IfIndex;ptr Next;ptr AdapterName;ptr FirstUnicastAddress;" & "ptr FirstAnycastAddress;ptr FirstMulticastAddress;ptr FirstDnsServerAddress;ptr DnsSuffix;ptr Description;" & "ptr FriendlyName;byte PhysicalAddress[8];dword PhysicalAddressLength;dword Flags;dword Mtu;dword IfType;int OperStatus;" & "dword Ipv6IfIndex;dword ZoneIndices[16];ptr FirstPrefix;" & "uint64 TransmitLinkSpeed;uint64 ReceiveLinkSpeed;ptr FirstWinsServerAddress;ptr FirstGatewayAddress;" & "ulong Ipv4Metric;ulong Ipv6Metric;uint64 Luid;STRUCT;ptr Dhcpv4ServerSockAddr;int Dhcpv4ServerSockAddrLen;ENDSTRUCT;" & "ulong CompartmentId;STRUCT;ulong NetworkGuidData1;word NetworkGuidData2;word NetworkGuidData3;byte NetworkGuidData4[8];ENDSTRUCT;" & "int ConnectionType;int TunnelType;STRUCT;ptr Dhcpv6ServerSockAddr;int Dhcpv6ServerSockAddrLen;ENDSTRUCT;byte Dhcpv6ClientDuid[130];" & "ulong Dhcpv6ClientDuidLength;ulong Dhcpv6Iaid;ptr FirstDnsSuffix;" Local $aRet, $nBufSize, $stBuffer, $stIP_ADAPTER_ADDRESSES, $pIPAAStruct, $nIPAAStSize Local $pTemp, $nTemp, $nEntries, $aIndexEntries $aRet = DllCall("iphlpapi.dll", "ulong", "GetAdaptersAddresses", "ulong", 0, "ulong", 0x86, "ptr", 0, "ptr", 0, "ulong*", 0) If @error Then Return SetError(1, @error, "") If $aRet[0] Then If $aRet[0] <> 111 Or Not $aRet[5] Then Return SetError(2, $aRet[0], "") EndIf $nBufSize = $aRet[5] $stBuffer = DllStructCreate("int64;byte [" & $nBufSize & "];") $aRet = DllCall("iphlpapi.dll", "ulong", "GetAdaptersAddresses", "ulong", 0, "ulong", 0x86, "ptr", 0, "ptr", DllStructGetPtr($stBuffer), "ulong*", $nBufSize) If @error Then Return SetError(1, @error, "") If $aRet[0] Then Return SetError(2, $aRet[0], "") Dim $aIndexEntries[Floor($nBufSize / 72)][2] $nEntries = 0 $pIPAAStruct = DllStructGetPtr($stBuffer) While $pIPAAStruct <> 0 $stIP_ADAPTER_ADDRESSES = DllStructCreate($tagIP_ADAPTER_ADDRESSES, $pIPAAStruct) $nIPAAStSize = DllStructGetData($stIP_ADAPTER_ADDRESSES, "Length") $nTemp = DllStructGetData($stIP_ADAPTER_ADDRESSES, "OperStatus") If ($nTemp = 2 And Not False) Or DllStructGetData($stIP_ADAPTER_ADDRESSES, "IfType") = 24 Then Else $pTemp = DllStructGetData($stIP_ADAPTER_ADDRESSES, "FirstUnicastAddress") If $pTemp <> 0 Then $aIndexEntries[$nEntries][0] = DllStructGetData($stIP_ADAPTER_ADDRESSES, "IfIndex") $aIndexEntries[$nEntries][1] = _GetStringW_FromPtr(DllStructGetData($stIP_ADAPTER_ADDRESSES, "FriendlyName")) $nEntries += 1 EndIf EndIf $pIPAAStruct = DllStructGetData($stIP_ADAPTER_ADDRESSES, "Next") WEnd If $nEntries = 0 Then Return SetError(-1, 0, "") ReDim $aIndexEntries[$nEntries][2] Return SetExtended($nEntries, $aIndexEntries) EndFunc ;==>_ListIndexInterfaceName Func InterfaceIndexSpeed($IfIndex) Local $tBuffer, $pBuffer, $iResult, $iSpeed $tBuffer = DllStructCreate("wchar[256];dword[5];byte[8];dword[16];char[256]") $pBuffer = DllStructGetPtr($tBuffer) DllStructSetData($tBuffer, 2, $IfIndex, 1) $iResult = DllCall("iphlpapi.dll", "long", "GetIfEntry", "ptr", $pBuffer) If @error Then Return SetError(@error, @extended, 0) $iSpeed = DllStructGetData($tBuffer, 2, 4) ;~ $sDescr = DllStructGetData($tBuffer, 5) $tBuffer = 0 Return SetError($iResult[0], $iSpeed / 1000 / 1000, $iSpeed) EndFunc ;==>InterfaceIndexSpeed Func _GetStringW_FromPtr($pStr) If Not IsPtr($pStr) Or $pStr = 0 Then Return SetError(1, 0, "") Local $aRet = DllCall("kernel32.dll", "ptr", "lstrcpynW", "wstr", "", "ptr", $pStr, "int", 32767) If @error Or Not $aRet[0] Then Return SetError(@error, 0, "") Return $aRet[1] EndFunc ;==>_GetStringW_FromPtr Func _GetMACFromIP($rMAC) If ($rMAC = "") Or ($rMAC = $sNotAvailable) Then Return $sNotAvailable Local $sbMAC = DllStructCreate("byte[6]") Local $siMAC = DllStructCreate("int") DllStructSetData($siMAC, 1, 6) Local $rHexMAC = DllCall("Ws2_32.dll", "int", "inet_addr", "str", $rMAC) $rMAC = $rHexMAC[0] $rHexMAC = DllCall("iphlpapi.dll", "int", "SendARP", "int", $rMAC, "int", 0, "ptr", DllStructGetPtr($sbMAC), "ptr", DllStructGetPtr($siMAC)) $rMAC = "" For $i = 0 To 5 If $i Then $rMAC &= ":" $rMAC = $rMAC & Hex(DllStructGetData($sbMAC, 1, $i + 1), 2) Next If ($rMAC = "") Or ($rMAC = $sBlankMAC) Or ($rMAC = $sNotAvailable) Then Return $sNotAvailable Return $rMAC EndFunc ;==>_GetMACFromIP ;==>_ByteSuffixRound Func _ByteSuffixRound($iBytes, $iRound = 2) $iBytes = Number($iBytes) If $iBytes > 1000000000 Then Return $sNotAvailable Local $A, $aArray[5] = ["Bps", "Kbps", "Mbps", "Gbps", "Tbps"] While $iBytes > 999 $A += 1 If $A > 3 Then ExitLoop $iBytes /= 1000 WEnd Return Round($iBytes, $iRound) & " " & $aArray[$A] EndFunc ;==>_ByteSuffixRound ;==>CreateContentCSV Func CreateContentCSV() Local $sContent If Not IsArray($sAdapterInfo) Then $sAdapterInfo = _GetListAdaptersInfo(".") If IsArray($sAdapterInfo) And $sAdapterInfo[0][0] > 0 Then $sContent &= '"NIC","InterfaceIndex","Adapter","AdapterName","AdapterStatus","GetIPType","IP","SubNetIP","MAC","GetwayIP","GetwayMAC","Speed","DNS1","DNS2","DNS3","DNS4","DNS5","DNS6","DNS7","DNS8"' & @CRLF For $x = 1 To $sAdapterInfo[0][0] $sContent &= '"' & $x & '",' $sContent &= '"' & $sAdapterInfo[$x][0] & '",' $sContent &= '"' & $sAdapterInfo[$x][1] & '",' $sContent &= '"' & $sAdapterInfo[$x][2] & '",' $sContent &= '"' & $sAdapterInfo[$x][3] & '",' $sContent &= '"' & $sAdapterInfo[$x][4] & '",' $sContent &= '"' & $sAdapterInfo[$x][5] & '",' $sContent &= '"' & $sAdapterInfo[$x][6] & '",' $sContent &= '"' & $sAdapterInfo[$x][7] & '",' $sContent &= '"' & $sAdapterInfo[$x][8] & '",' $sContent &= '"' & $sAdapterInfo[$x][9] & '",' $sContent &= '"' & $sAdapterInfo[$x][10] & '",' $sContent &= '"' & $sAdapterInfo[$x][11] & '",' $sContent &= '"' & $sAdapterInfo[$x][12] & '",' $sContent &= '"' & $sAdapterInfo[$x][13] & '",' $sContent &= '"' & $sAdapterInfo[$x][14] & '",' $sContent &= '"' & $sAdapterInfo[$x][15] & '",' $sContent &= '"' & $sAdapterInfo[$x][16] & '",' $sContent &= '"' & $sAdapterInfo[$x][17] & '",' $sContent &= '"' & $sAdapterInfo[$x][18] & '"' & @CRLF Next Return $sContent Else Return SetError(1, 0, False) EndIf EndFunc ;==>CreateContentCSV ;==>CreateContentINI Func CreateContentINI() Local $sContent = "[NetworkInfo]" & @CRLF $sContent &= "Time = " & @YEAR & "/" & @MON & "/" & @MDAY & "-" & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF If Not IsArray($sAdapterInfo) Then $sAdapterInfo = _GetListAdaptersInfo(".") If IsArray($sAdapterInfo) And $sAdapterInfo[0][0] > 0 Then $sContent &= "TotalNIC = " & $sAdapterInfo[0][0] & @CRLF & @CRLF For $x = 1 To $sAdapterInfo[0][0] $sContent &= "[NIC" & $x & "]" & @CRLF $sContent &= "InterfaceIndex = " & $sAdapterInfo[$x][0] & @CRLF $sContent &= "Adapter = " & $sAdapterInfo[$x][1] & @CRLF $sContent &= "AdapterName = " & $sAdapterInfo[$x][2] & @CRLF $sContent &= "AdapterStatus = " & $sAdapterInfo[$x][3] & @CRLF $sContent &= "GetIPType = " & $sAdapterInfo[$x][4] & @CRLF $sContent &= "IP = " & $sAdapterInfo[$x][5] & @CRLF $sContent &= "SubNetIP = " & $sAdapterInfo[$x][6] & @CRLF $sContent &= "MAC = " & $sAdapterInfo[$x][7] & @CRLF $sContent &= "GetwayIP = " & $sAdapterInfo[$x][8] & @CRLF $sContent &= "GetwayMAC = " & $sAdapterInfo[$x][9] & @CRLF $sContent &= "Speed = " & $sAdapterInfo[$x][10] & @CRLF & @CRLF $sContent &= "DNS1 = " & $sAdapterInfo[$x][11] & @CRLF $sContent &= "DNS2 = " & $sAdapterInfo[$x][12] & @CRLF $sContent &= "DNS3 = " & $sAdapterInfo[$x][13] & @CRLF $sContent &= "DNS4 = " & $sAdapterInfo[$x][14] & @CRLF $sContent &= "DNS5 = " & $sAdapterInfo[$x][15] & @CRLF $sContent &= "DNS6 = " & $sAdapterInfo[$x][16] & @CRLF $sContent &= "DNS7 = " & $sAdapterInfo[$x][17] & @CRLF $sContent &= "DNS8 = " & $sAdapterInfo[$x][18] & @CRLF Next Return $sContent Else Return SetError(1, 0, False) EndIf EndFunc ;==>CreateContentINI ;==>_CheckConnect Binary and Source:
    1 point
  6. CountyIT, The StringSize UDF in my sig is exactly what you want - it returns the pixel size of any string in any font. If you have any questions about its use then please do ask - preferably in the UDF thread itself so others can benefit as well. M23
    1 point
×
×
  • Create New...