Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Tips & tricks

#772 - Hämta Domän namn med API och IP Adress kontrollen i CommonControls

Postat 2001-08-30 11:23:04 av Peter Aronsson i Kategori Programmering, C#, Kommandon med 0 Kommentarer

' *** Place the following code in a form window. ***

Private hIPControl As Long ' handle to the IP Address control

' When the form is initialized, create an IP Address control in the
' upper-left corner of the form.
Private Sub Form_Initialize()
Dim comctls As INITCOMMONCONTROLSEX_TYPE ' identifies the control to register
Dim retval As Long ' generic return value

' Register the IP Address control window class.
With comctls
.dwSize = Len(comctls)
.dwICC = ICC_INTERNET_CLASSES
End With
retval = InitCommonControlsEx(comctls)

' Create the IP Address control in the corner of the window.
hIPControl = CreateWindowEx(0, WC_IPADDRESS, "", WS_CHILD Or WS_VISIBLE, 0, 0, 125, 20, _
Me.hWnd, 0, App.hInstance, ByVal CLng(0))
End Sub

' Destroy the IP Address control when the form closes.
Private Sub Form_Unload(Cancel As Integer)
Dim retval As Long ' return value

retval = DestroyWindow(hIPControl)
End Sub

' Look up the primary domain name of the host computer identified by the
' address in the IP Address control.
Private Sub cmdGetDomain_Click()
Dim ipAddress_h As Long ' the IP address, in host byte order
Dim ipAddress_n As Long ' the IP address, in network byte order
Dim sockinfo As WSADATA ' information about the Winsock implementation
Dim pHostinfo As Long ' pointer to information about the host computer
Dim hostinfo As HOSTENT ' information about the host computer
Dim domainName As String ' the primary domain name of the host computer
Dim retval As Long ' generic return value

' Verify that an IP address was entered.
retval = SendMessage(hIPControl, IPM_ISBLANK, ByVal CLng(0), ByVal CLng(0))
If retval <> 0 Then
Debug.Print "No IP address was entered!"
Exit Sub
End If

' Get the IP address entered by the user and verify that all
' four fields in the address were entered.
retval = SendMessage(hIPControl, IPM_GETADDRESS, ByVal CLng(0), ipAddress_h)
If retval < 4 Then
Debug.Print "An incomplete IP address was entered!"
Exit Sub
End If

' Open up a Winsock v2.2 session.
retval = WSAStartup(&H202, sockinfo)
If retval <> 0 Then
Debug.Print "ERROR: Attempt to open Winsock failed: error"; retval
Exit Sub
End If

' Convert the IP address into network byte order.
ipAddress_n = htonl(ipAddress_h)
' Get information about the host computer.
pHostinfo = gethostbyaddr(ipAddress_n, 4, AF_INET)
If pHostinfo = 0 Then
Debug.Print "Could not find a host with the specified IP address."
Else
' Copy the data into the structure.
CopyMemory hostinfo, ByVal pHostinfo, Len(hostinfo)
' Copy the host domain name into a string.
domainName = Space(lstrlen(hostinfo.h_name))
retval = lstrcpy(domainName, hostinfo.h_name)
Debug.Print "Domain name is: "; domainName
End If

' End the Winsock session.
retval = WSACleanup()
End Sub

Sample:
Size:

Nyligen

  • 09:09 Vill du köpa medicinska tester?
  • 12:47 Vem beviljar assistansen – kommune
  • 14:17 Någon med erfarenhet av hemstädnin
  • 14:14 Bör man använda sig av en båtförme
  • 14:12 Finns det någon intressant hundblo
  • 14:25 Tips på verktyg för att skapa QR-k
  • 14:23 Tips på verktyg för att skapa QR-k
  • 20:52 Fungerer innskuddsbonuser egentlig

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 569 153
27 952
271 704
860
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies