PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 22 → Windev - Ativacao de Serial Unica para Aplicativo, Usando Webservice e Api do Windows
Windev - Ativacao de Serial Unica para Aplicativo, Usando Webservice e Api do Windows
Débuté par adrianoboller, 06 juil. 2015 22:06 - 3 réponses
Membre enregistré
2 852 messages
Popularité : +89 (91 votes)
Posté le 06 juillet 2015 - 22:06




//SERIAL
EDT_Hard_Drive = ""
EDT_Serial = ""

sBaseBoardManufacturer, sBaseBoardProduct, sBaseBoardVersion, sBIOSReleaseDate, sBIOSVendor, sBIOSVersion, sSystemFamily, sSystemManufacturer is string = ""

ResExist1 is boolean = RegistryExist("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS")

ResExist2 is boolean = RegistryExist("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0")

IF ResExist1 = True AND ResExist2 = True

sKey is string = "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS"

sBaseBoardManufacturer = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardManufacturer", True)
sBaseBoardProduct = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardProduct", True)
sBaseBoardVersion = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardVersion", True)
sBIOSReleaseDate = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BIOSReleaseDate", True)
sBIOSVendor = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BIOSVendor", True)
sBIOSVersion = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BIOSVersion", True)
sSystemFamily = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemFamily", True)
sSystemManufacturer = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemManufacturer", True)

EDT_Processador = RegistryQueryValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", True)

EDT_Placa_Mae = sBaseBoardManufacturer +"-"+ sBaseBoardProduct +"-"+ sBaseBoardVersion +"-"+ sBIOSReleaseDate +"-"+ sBIOSVendor +"-"+ sBIOSVersion +"-"+ sSystemFamily +"-"+ sSystemManufacturer
END

//EDT_Hard_Drive ====> Envia para o Webservice
EDT_Hard_Drive = fDisqueInfo(Middle(SysDir(srWindows),1,2),fdSerialNumber)

EDT_IP_4 = NetIPAddress()

EDT_Placa_de_Rede_Mac = Upper(NetMACAddress())

EDT_Version_Windows = SysWindowsVersion(sysProcessor) +" bits - "+ SysWindowsVersion(sysVersionBuild) +"-"+ SysWindowsVersion(sysVersionInfo) +"-"+ SysWindowsVersion(sysVersionNumber) +"-"+ SysWindowsVersion(sysVersionPlatform)

EDT_Name_PC = Upper(NetMachineName())

//Crypto
EDT_Serial = EDT_Company +"; "+ EDT_CNPJ_CPF_ID +"; "+ EDT_Processador +"; "+ EDT_Placa_Mae +"; "+ EDT_Hard_Drive +"; "+ EDT_IP_4 +"; "+ EDT_Placa_de_Rede_Mac +"; "+ EDT_Version_Windows +"; "+ EDT_Name_PC
EDT_Serial = Crypt(EDT_Serial,EDT_Hard_Drive,cryptAnsi+compressShortString,encodeBASE64) // ===> Envia para o Webservice da Empresa


IF InternetConnected() = True THEN

ok is boolean = HTTPRequest("http://www.empresa.com.br")

IF ok = True

Info("The server is OK")

//SEND ID
// Token
//
// EDT_Hard_Drive
//
// EDT_Serial


Token is string = EDT_CNPJ_CPF_ID // cpf é a chave no cadastro na sua empresa

Info(Token, EDT_Hard_Drive, EDT_Serial)

//Send webservice parameters
//if ok = true THEN
//GET ID OK IN WEBSERVICE BATE COM OS DADOS FAZENDO UNCRYPT ENTAO

//AO ABRIR E AO SALVAR
//else
IF YesNo("Deseja desativar o serial do computador x"+CR+"e ativar para este computador y") = Yes

//Envia webservice com os novos dados

Info("Serial ativado para esse computador")

END
//END

ELSE
Info("Server temporarily unavailable")
END
Membre enregistré
2 852 messages
Popularité : +89 (91 votes)
Posté le 06 juillet 2015 - 22:15
//Verificar

EDT_Serial_Servidor = ""

EDT_Serial_Servidor = Uncrypt(EDT_Serial, EDT_Hard_Drive, cryptAnsi+compressShortString,encodeBASE64)
=
IF PositionOccurrence(EDT_Serial_Servidor , EDT_Hard_Drive, firstRank,FromBeginning) > 0
STC_Resultado = "Serial Valido"
STC_Resultado..Color = DarkBlue
ELSE
STC_Resultado = "Serial não é Valido"
STC_Resultado..Color = DarkRed
//Valida com o retorno do webservice se existe ou nao
IF CBOX_Simular..Value = False
IF YesNo("Deseja desativar o serial do computador x"+CR+"e ativar para este computador y") = Yes

//Envia webservice com os novos dados

Info("Serial ativado para esse computador")

END
END

END
Membre enregistré
2 852 messages
Popularité : +89 (91 votes)
Posté le 07 juillet 2015 - 02:48
//Criando Chave e Valor de Registro do Windows

bResCreateKey is boolean = RegistryCreateKey("HKEY_LOCAL_MACHINE\SOFTWARE\SOFTHOUSE")

bCHAVE_WB is boolean = RegistrySetValue("HKEY_LOCAL_MACHINE\SOFTWARE\SOFTHOUSE", "SYSCLINICA", EDT_Serial)

//EDT_Serial = Chave Cryptografada enviada para o webservice da sua empresa
Membre enregistré
1 message
Posté le 24 février 2018 - 17:00
Bom exemplo Adriano, parabéns.