From: Takumo on 25 Feb 2010 15:52 On 21 Ñев, 15:01, "richard.townsendrose" <richard.townsendr...(a)googlemail.com> wrote: > Geoff > > Haven't tested on the machines which throw errors ... > > What we do is > a) get the serial number > b) encrypt it and send the codes > c) when i decrypt the codes - i am getting junk ... > > // get serial > dwSerial:=GeoffGetDiskSerialNumber() > IF dwSerial == 0           // rgtr 180408 >     cWhere:='B1a' >     BREAK > ENDIF > id:=AsString(dwSerial) > IF Len(id) > 11           // >>>>>>> may be this is the > problem ???? >     id:=SubStr(id,1,11) > ENDIF > cEncCode:=GetCodes(Crypt(id, SELF:cCode), TRUE) > > we split into four parts ... >     SELF:oDCEncCode1:Value:=SubStr(aData[1],1, 6) >     SELF:oDCEncCode2:Value:=SubStr(aData[1],7, 6) >     SELF:oDCEncCode3:Value:=SubStr(aData[1],13,6) >     SELF:oDCEncCode4:Value:=SubStr(aData[1],19,6) > and this is what is sent ... > > richard Hi, Richard! It seems that this limitation (IF Len(id) > 11) is obsolete. According to the example in MS.W7SDKCOM (Win32_PhysicalMedia Class); .... SerialNumber Data type: string Access type: Read-only Manufacturer-allocated number used to identify the physical media. Example: WD-WM3493798728. I failed to find the length of this string (SerialNumber), but the given example is 15 characters long. In this case your routine will obviously fail while comparing two numbers. Maybe it is useful to make buffer as long as MAX_PATH and then Rtrim it. HTH.
From: Geoff Schaller on 25 Feb 2010 16:36 Good idea. "Takumo" <advokat.bond(a)gmail.com> wrote in message news:39144a4d-eca8-4ec6-8978-787eb3f10439(a)33g2000yqj.googlegroups.com: > On 21 ���, 15:01, "richard.townsendrose" > <richard.townsendr...(a)googlemail.com> wrote: > > > Geoff > > > > Haven't tested on the machines which throw errors ... > > > > What we do is > > a) get the serial number > > b) encrypt it and send the codes > > c) when i decrypt the codes - i am getting junk ... > > > > // get serial > > dwSerial:=GeoffGetDiskSerialNumber() > > IF dwSerial == 0 // rgtr 180408 > > cWhere:='B1a' > > BREAK > > ENDIF > > id:=AsString(dwSerial) > > IF Len(id) > 11 // >>>>>>> may be this is the > > problem ???? > > id:=SubStr(id,1,11) > > ENDIF > > cEncCode:=GetCodes(Crypt(id, SELF:cCode), TRUE) > > > > we split into four parts ... > > SELF:oDCEncCode1:Value:=SubStr(aData[1],1, 6) > > SELF:oDCEncCode2:Value:=SubStr(aData[1],7, 6) > > SELF:oDCEncCode3:Value:=SubStr(aData[1],13,6) > > SELF:oDCEncCode4:Value:=SubStr(aData[1],19,6) > > and this is what is sent ... > > > > richard > > > Hi, Richard! > It seems that this limitation (IF Len(id) > 11) is obsolete. > According to the example in MS.W7SDKCOM (Win32_PhysicalMedia Class); > ... > SerialNumber > Data type: string > Access type: Read-only > > Manufacturer-allocated number used to identify the physical media. > > Example: WD-WM3493798728. > I failed to find the length of this string (SerialNumber), but the > given example is 15 characters long. In this case your routine will > obviously fail while comparing two numbers. > Maybe it is useful to make buffer as long as MAX_PATH and then Rtrim > it. > HTH.
From: Geoff Schaller on 6 Mar 2010 06:35 Richard, I need to correct something here. The number return here is NOT the disk serial number but the volume number - which is something Windows assigns the drive (and virtual drives etc) when they are created. The "serial" number is something else. The Volume number is always a number and always <4GB. It has a maximum length of 10 digits. Geoff PS - you can get the SERIAL number in C# like this: //Namespace Reference using System.Management /// <summary> /// method to retrieve the selected HDD's serial number /// </summary> /// <param name="strDriveLetter">Drive letter to retrieve serial number for</param> /// <returns>the HDD's serial number</returns> public string GetHDDSerialNumber(string drive) { //check to see if the user provided a drive letter //if not default it to "C" if (drive == "" || drive == null) { drive = "C"; } //create our ManagementObject, passing it the drive letter to the //DevideID using WQL ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"" + drive +":\""); //bind our management object disk.Get(); //return the serial number return disk["VolumeSerialNumber"].ToString(); } "richard.townsendrose" <richard.townsendrose(a)googlemail.com> wrote in message news:d428fd64-1c56-417a-babb-3cbe62699943(a)f15g2000yqe.googlegroups.com: > Hi All and Geoff > > for years we have been using the code below from geoff ... > > suddenly with windows 7 it stops working ... > > can one set the currenmt default partition viz the one with drive c: ? > > anyone any ideas, > > richard > > ************************* > > FUNCTION GeoffGetDiskSerialNumber( ) AS DWORD STRICT > // Obtains the formatted serial number from the CURRENT default > partition. > // this number is relatively unique: 1 in 4,000,000,000 > LOCAL pszBuffer AS PTR > LOCAL dwMaxLength AS DWORD > LOCAL dwFileSystemFlags AS DWORD > LOCAL pszFileSystemName AS PTR > LOCAL dwOldMode AS DWORD > LOCAL dwSerial AS DWORD > LOCAL cDisk AS STRING > > > pszBuffer := MemAlloc( MAX_PATH + 1 ) > pszFileSystemName := MemAlloc( MAX_PATH + 1 ) > // Pass cDisk if a universal routine is required > cDisk := DiskName() + ":\" > // To Avoid errors if the Drives doesn't exist > dwOldMOde := SetErrorMode( SEM_FAILCRITICALERRORS ) > // Get info > IF !GetVolumeInformation( ; > PSZ(_CAST, cDisk ), ; > pszBuffer, ; > MAX_PATH, ; > @dwSerial, ; > @dwMaxLength, ; > @dwFileSystemFlags, ; > pszFileSystemName, ; > MAX_PATH ) > > RETURN 0 > ENDIF > // Reset Error Mode > SetErrorMode( dwOldMode ) > MemFree( pszBuffer ) > MemFree( pszFileSystemName ) > > // Now adjust for silly numbers which will muck up security. > largest DWORD is 4,294,967,295 > IF dwSerial > DWORD(4100000000) > dwSerial := dwSerial - DWORD(999999999) > ELSEIF dwSerial < DWORD(999999999) > dwSerial := dwSerial + DWORD(999999999) > ENDIF > > RETURN dwSerial
From: Willie Moore on 6 Mar 2010 08:10 Geoff, Here is the Vulcan version of your function for all the folks who want to call this from Vulcan without creating the c# dll. Thanks for posting your snippet. It was very handy!! Regards, Willie // Application : SerialNumber // start.prg , Created : 3/6/2010 6:35 AM //Namespace Reference #USING System.Management #USING System.Windows.Forms FUNCTION Start() AS VOID LOCAL cSerial AS STRING TRY cSerial := GetHDDSerialNumber("C") MessageBox.Show(cSerial) CATCH ex AS Exception MessageBox.Show(ex:ToString()) END TRY RETURN /// <summary> /// method to retrieve the selected HDD's serial number /// </summary> /// <param name="strDriveLetter">Drive letter to retrieve serial number for</param> /// <returns>the HDD's serial number</returns> FUNCTION GetHDDSerialNumber(drive AS STRING) LOCAL disk AS ManageMentObject //check to see if the user provided a drive letter //if not default it to "C" IF drive == "" .or. drive == NULL drive := "C" ENDIF //create our ManagementObject, passing it the drive letter to the //DevideID using WQL disk := ManagementObject{String.Concat("win32_logicaldisk.deviceid="+chr(34), drive, ":"+chr(34))} //bind our management object disk:Get() //return the serial number RETURN disk["VolumeSerialNumber"]:ToString() "Geoff Schaller" <geoffx(a)softxwareobjectives.com.au> wrote in message news:n6rkn.11513$pv.9412(a)news-server.bigpond.net.au: > Richard, > > I need to correct something here. The number return here is NOT the disk > serial number but the volume number - which is something Windows assigns > the drive (and virtual drives etc) when they are created. > > The "serial" number is something else. > > The Volume number is always a number and always <4GB. > It has a maximum length of 10 digits. > > Geoff > > PS - you can get the SERIAL number in C# like this: > > //Namespace Reference > using System.Management > > /// <summary> > /// method to retrieve the selected HDD's serial number > /// </summary> > /// <param name="strDriveLetter">Drive letter to retrieve serial number > for</param> > /// <returns>the HDD's serial number</returns> > public string GetHDDSerialNumber(string drive) > { > //check to see if the user provided a drive letter > //if not default it to "C" > if (drive == "" || drive == null) > { > drive = "C"; > } > //create our ManagementObject, passing it the drive letter to the > //DevideID using WQL > ManagementObject disk = new > ManagementObject("win32_logicaldisk.deviceid=\"" + drive +":\""); > //bind our management object > disk.Get(); > //return the serial number > return disk["VolumeSerialNumber"].ToString(); > } > > > > "richard.townsendrose" <richard.townsendrose(a)googlemail.com> wrote in > message > news:d428fd64-1c56-417a-babb-3cbe62699943(a)f15g2000yqe.googlegroups.com: > > > > Hi All and Geoff > > > > for years we have been using the code below from geoff ... > > > > suddenly with windows 7 it stops working ... > > > > can one set the currenmt default partition viz the one with drive c: ? > > > > anyone any ideas, > > > > richard > > > > ************************* > > > > FUNCTION GeoffGetDiskSerialNumber( ) AS DWORD STRICT > > // Obtains the formatted serial number from the CURRENT default > > partition. > > // this number is relatively unique: 1 in 4,000,000,000 > > LOCAL pszBuffer AS PTR > > LOCAL dwMaxLength AS DWORD > > LOCAL dwFileSystemFlags AS DWORD > > LOCAL pszFileSystemName AS PTR > > LOCAL dwOldMode AS DWORD > > LOCAL dwSerial AS DWORD > > LOCAL cDisk AS STRING > > > > > > pszBuffer := MemAlloc( MAX_PATH + 1 ) > > pszFileSystemName := MemAlloc( MAX_PATH + 1 ) > > // Pass cDisk if a universal routine is required > > cDisk := DiskName() + ":\" > > // To Avoid errors if the Drives doesn't exist > > dwOldMOde := SetErrorMode( SEM_FAILCRITICALERRORS ) > > // Get info > > IF !GetVolumeInformation( ; > > PSZ(_CAST, cDisk ), ; > > pszBuffer, ; > > MAX_PATH, ; > > @dwSerial, ; > > @dwMaxLength, ; > > @dwFileSystemFlags, ; > > pszFileSystemName, ; > > MAX_PATH ) > > > > RETURN 0 > > ENDIF > > // Reset Error Mode > > SetErrorMode( dwOldMode ) > > MemFree( pszBuffer ) > > MemFree( pszFileSystemName ) > > > > // Now adjust for silly numbers which will muck up security. > > largest DWORD is 4,294,967,295 > > IF dwSerial > DWORD(4100000000) > > dwSerial := dwSerial - DWORD(999999999) > > ELSEIF dwSerial < DWORD(999999999) > > dwSerial := dwSerial + DWORD(999999999) > > ENDIF > > > > RETURN dwSerial __________ Information from ESET NOD32 Antivirus, version of virus signature database 4920 (20100306) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com
From: Geoff Schaller on 6 Mar 2010 18:27 Cool - cooperative development again <g> "Willie Moore" <williem(a)wmconsulting.com> wrote in message news:hmtk7q$v0m$1(a)speranza.aioe.org: > Geoff, > > Here is the Vulcan version of your function for all the folks who want > to call this from Vulcan without creating the c# dll. Thanks for posting > your snippet. It was very handy!! > > Regards, > Willie
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: VO 2.8 and what happened to my colors? Next: Application Icon |