From: richard.townsendrose on 20 Feb 2010 05:14 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: dlzc on 20 Feb 2010 14:23 On Feb 20, 3:14 am, "richard.townsendrose" <richard.townsendr...(a)googlemail.com> wrote: .... > suddenly with windows 7 it stops working ... > > can one set the currenmt default partition viz > the one with drive c: ? I find disk serial numbers here... as an ASCII-Z character string: HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\Scsi Port 2\Scsi Bus 0\Target Id 0\Logical Unit Id 0\SerialNumber HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\Scsi Port 2\Scsi Bus 1\Target Id 1\Logical Unit Id 0\SerialNumber .... needless to say I have two hard drives in my machine. They are not both available to Windoze 7, 64-bit. And neither is Scsi. No other entries in HCM. Doubt this helps. David A. Smith
From: Geoff Schaller on 20 Feb 2010 17:24 Richard, What do you mean 'stops'. The function works just as expected on my 64 bit W7 PC. It worked on all Vista versions and on a 32 bit W7 as well. This is a Win32 API call - of course C# has some superior ways to do this but this still works. Can you explain which bit goes wrong for you? Geoff "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: richard.townsendrose on 21 Feb 2010 07:01 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
From: Geoff Schaller on 21 Feb 2010 15:54
Ah so it may not be my function at all! Did you look at the source code to the function? You will see your length gizmo is redundant but I suspect your encrypting routine is at fault, not my function. Geoff "richard.townsendrose" <richard.townsendrose(a)googlemail.com> wrote in message news:3f445e40-a076-4791-b9ea-210220c1a77c(a)j27g2000yqn.googlegroups.com: > 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 |