Option Explicit
'----------------------------------------------------------------------------
'This module contains 3 functions for determing the public IP, the local IP
'and the MAC address of the computer that runs those functions.
'Written By: Christos Samaras
'Date: 22/11/2014
'E-mail: <לא ניתן לפרסם מיילים באופן פומבי>
'Site: http://www.myengineeringworld.net
'----------------------------------------------------------------------------
Function GetMyPublicIP() As String
Dim HttpRequest As Object
On Error Resume Next
'Create the XMLHttpRequest object.
Set HttpRequest = CreateObject("MSXML2.XMLHTTP")
'Check if the object was created.
If Err.Number <> 0 Then
'Return error message.
GetMyPublicIP = "Could not create the XMLHttpRequest object!"
'Release the object and exit.
Set HttpRequest = Nothing
Exit Function
End If
On Error GoTo 0
'Create the request - no special parameters required.
HttpRequest.Open "GET", "http://myip.dnsomatic.com", False
'Send the request to the site.
HttpRequest.Send
'Return the result of the request (the IP string).
GetMyPublicIP = HttpRequest.ResponseText
End Function
Function GetMyLocalIP() As String
'Declaring the necessary variables.
Dim strComputer As String
Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Dim myIPAddress 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 IP addresses from the network adapters that have the property IPEnabled equal to true.
Set colItems = objWMIService.ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
'Loop through all the objects of the collection and return the first non-empty IP.
For Each objItem In colItems
If Not IsNull(objItem.IPAddress) Then myIPAddress = Trim(objItem.IPAddress(0))
Exit For
Next
'Return the IP string.
GetMyLocalIP = myIPAddress
End Function
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 = myMACAddress
End Function
Function GetSerialNumber() As String
Dim fsObj As Object
Dim drv As Object
Dim HDSerialNumber As String
Dim strAllNumber As String
Set fsObj = CreateObject("Scripting.FileSystemObject")
Set drv = fsObj.Drives(Left(CurrentProject.Path, 1))
HDSerialNumber = Hex(drv.SerialNumber)
GetSerialNumber = parseNum(HDSerialNumber)
End Function
Function parseNum(strSearch As String) As String
Dim i As Integer
Dim tempVal As String
For i = 1 To Len(strSearch)
If IsNumeric(Mid(strSearch, i, 1)) Then
tempVal = tempVal + Mid(strSearch, i, 1)
End If
Next
parseNum = tempVal
End Function
Dim strKode As String
Dim strSerialKode As String
Dim inputGetNumber As String
strSerialKode = Round(GetSerialNumber * 10/10/2*50 , 0) ''חישוב שלך
strKode = DLookup("number", "tblnumber")
If strKode <> strSerialKode Then
inputGetNumber = InputBox("התוכנה אינה רשומה!" & vbCrLf & "קוד נעילה: " & GetSerialNumber)
If inputGetNumber = Round(GetSerialNumber * * 10/10/2*50, 0) Then ''חישוב שלך
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblNumber SET tblNumber.[Number] = " & inputGetNumber
DoCmd.SetWarnings True
MsgBox "נרשם בהצלחה!" & vbCrLf & "תודה שרכשת את אימון התוכנה.", vbMsgBoxRight + vbMsgBoxRtlReading
Else
MsgBox "שגיאת רישום, פנה ל ... לקבלת הקוד" & vbCrLf & "התוכנה נסגרת!!!", vbMsgBoxRight + vbMsgBoxRtlReading
Cancel = True
End If
End If
רק צריך לדעת שאחרי פירמוט הסריאל שהפונקציה הזו מחזירה היא שונה.זה יתן לך את הסריאל של המחשב.
קוד:Function GetSerialNumber() As String Dim fsObj As Object Dim drv As Object Dim HDSerialNumber As String Dim strAllNumber As String Set fsObj = CreateObject("Scripting.FileSystemObject") Set drv = fsObj.Drives(Left(CurrentProject.Path, 1)) HDSerialNumber = Hex(drv.SerialNumber) GetSerialNumber = parseNum(HDSerialNumber) End Function
ומתי הסריאל מתפרמט?רק צריך לדעת שאחרי פירמוט הסריאל שהפונקציה הזו מחזירה היא שונה.
הסריאל שהפונקציה מחזירה הוא סריאל לוגי. תבדוק על דיסק און קי, אחרי כל פירמוט הסריאל ישתנה.ומתי הסריאל מתפרמט?
כבר כתבתי לך פתרון, להשתמש עם הכתובת מאק.אני צריך משהו שלא משתנה אף פעם
תודה רבה
הכתובת הזאת לא משתנה אף פעם?כבר כתבתי לך פתרון, להשתמש עם הכתובת מאק.
והאם יש דרך למצוא את השם משתמש?
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
לרוב המשתמשים באינטרנט בישראל יש אייפי דינמי, כלומר אייפי שמשתנה מידי פעם. אצל מרבית הספקים ניתן לקבל אייפי קבוע בתוספת תשלום.וה-IP משתנה מתישהו?
המאק לא קשור לדיסק קשיח הוא קשור לכרטיס רשת.בס"ד
אם מחליפים את הדיסק קשיח ממחשב למחשב (בנייד מצוי מאוד)
הMAC נשאר פתרון?
rhon.co.il
מעכשיו, תהיו הראשונים לקבל את כל העדכונים, החדשות, ההפתעות בלעדיות, והתכנים הכי חמים שלנו בפרוג!
חלה שגיאה בשליחה. נסו שוב!
לוח לימודים
מסלולי לימוד שאפשר להצטרף
אליהם ממש עכשיו:
תהילים פרק כה
אלְדָוִד אֵלֶיךָ יי נַפְשִׁי אֶשָּׂא:באֱלֹהַי בְּךָ בָטַחְתִּי אַל אֵבוֹשָׁה אַל יַעַלְצוּ אֹיְבַי לִי:גגַּם כָּל קוֶֹיךָ לֹא יֵבֹשׁוּ יֵבֹשׁוּ הַבּוֹגְדִים רֵיקָם:דדְּרָכֶיךָ יי הוֹדִיעֵנִי אֹרְחוֹתֶיךָ לַמְּדֵנִי:ההַדְרִיכֵנִי בַאֲמִתֶּךָ וְלַמְּדֵנִי כִּי אַתָּה אֱלֹהֵי יִשְׁעִי אוֹתְךָ קִוִּיתִי כָּל הַיּוֹם:וזְכֹר רַחֲמֶיךָ יי וַחֲסָדֶיךָ כִּי מֵעוֹלָם הֵמָּה:זחַטֹּאות נְעוּרַי וּפְשָׁעַי אַל תִּזְכֹּר כְּחַסְדְּךָ זְכָר לִי אַתָּה לְמַעַן טוּבְךָ יי:חטוֹב וְיָשָׁר יי עַל כֵּן יוֹרֶה חַטָּאִים בַּדָּרֶךְ:טיַדְרֵךְ עֲנָוִים בַּמִּשְׁפָּט וִילַמֵּד עֲנָוִים דַּרְכּוֹ:יכָּל אָרְחוֹת יי חֶסֶד וֶאֱמֶת לְנֹצְרֵי בְרִיתוֹ וְעֵדֹתָיו:יאלְמַעַן שִׁמְךָ יי וְסָלַחְתָּ לַעֲוֹנִי כִּי רַב הוּא:יבמִי זֶה הָאִישׁ יְרֵא יי יוֹרֶנּוּ בְּדֶרֶךְ יִבְחָר:יגנַפְשׁוֹ בְּטוֹב תָּלִין וְזַרְעוֹ יִירַשׁ אָרֶץ:ידסוֹד יי לִירֵאָיו וּבְרִיתוֹ לְהוֹדִיעָם:טועֵינַי תָּמִיד אֶל יי כִּי הוּא יוֹצִיא מֵרֶשֶׁת רַגְלָי:טזפְּנֵה אֵלַי וְחָנֵּנִי כִּי יָחִיד וְעָנִי אָנִי:יזצָרוֹת לְבָבִי הִרְחִיבוּ מִמְּצוּקוֹתַי הוֹצִיאֵנִי:יחרְאֵה עָנְיִי וַעֲמָלִי וְשָׂא לְכָל חַטֹּאותָי:יטרְאֵה אוֹיְבַי כִּי רָבּוּ וְשִׂנְאַת חָמָס שְׂנֵאוּנִי:כשָׁמְרָה נַפְשִׁי וְהַצִּילֵנִי אַל אֵבוֹשׁ כִּי חָסִיתִי בָךְ:כאתֹּם וָיֹשֶׁר יִצְּרוּנִי כִּי קִוִּיתִיךָ:כבפְּדֵה אֱלֹהִים אֶת יִשְׂרָאֵל מִכֹּל צָרוֹתָיו:
הנושאים החמים