Keil5注册机用法介绍(keil5注册机用法)

Keil5是一款非常好用的嵌入式开发工具,但是它是付费软件,需要注册才能使用全部功能。今天我们将围绕Keil5注册机展开讨论,介绍Keil5注册机的各个方面,让您深入了解这个工具。

一、Keil5注册机的原理

Keil5是依靠芯片烧录器与芯片通信完成注册的,因此我们要对它进行注册,需要拥有芯片烧录器,这个就是Keil5注册机的背景。

Keil5注册机的原理其实很简单,就是通过修改Keil5的配置文件。先记录你的电脑MAC地址,然后将其进行MD5加密,得到注册码,将该注册码与芯片烧录器通信,即可完成注册。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <windows.h>
#include <wincrypt.h>
#include <conio.h>
#include "MD5.h"

int CheckSerial(void);

int md5_str2key(char *str, char *key) {
    MD5_CTX md5;
    unsigned char md[16];
    int i;
    char tbuf[3];

    MD5Init(&md5);
    MD5Update(&md5, (unsigned char*)str, strlen(str));
    MD5Final(&md5, md);

    for (i = 0; i < 16; i++) {
        sprintf(tbuf, "%02x", md[i]);
        memcpy(&key[i * 2], tbuf, 2);
    }

    key[32] = 0;

    return 0;
}

int main(int argc, char* argv[]) {
    BYTE byReadData[1024] = { 0 };
    char szSerial[64] = { 0 };
    DWORD dwLength = 0;
    HCRYPTPROV hCryptProv = 0;
    HCRYPTHASH hHash = 0;
    BYTE Data[] = "10223^E5 642T8";
    CHAR HashValue[16] = { 0 };
    DWORD HashValueLength = 16;

    if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
        if (CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash)) {
            if (CryptHashData(hHash, Data, sizeof(Data), 0)) {
                if (CryptGetHashParam(hHash, HP_HASHVAL, HashValue, &HashValueLength, 0)) {
                    printf("Hash Value:n");
                    for (int i = 0; i < 16; i++)
                        printf("%c", HashValue[i]);
                }
            }
        }
    }
}

以上是Keil5注册机的基本代码,其中使用框架中的MD5算法来生成注册码,再调用芯片烧录器进行注册即可。

二、Keil5注册机的使用步骤

Keil5注册机的使用步骤分为如下几步:

第一步:打开Keil5注册机,记录电脑MAC地址,生成机器码。

第二步:将生成的机器码复制到Keil5注册机中,再点击“生成”,生成注册码。

第三步:将生成的注册码输入到注册界面中,完成Keil5的注册。

注意:要使用注册机,前提是您已经安装好了Keil5,并且拥有芯片烧录器。

三、Keil5注册机验证码处理方式

为了防止盗版,Keil5在注册时会进行验证码校验。如果验证码不正确,将无法完成注册。但是,我们可以利用Keil5注册机的验证码处理功能,直接让Keil5跳过验证码,完成注册。

#include<stdio.h>
#include<conio.h>
#include<ctype.h>

int CheckSerial(void);

main()
{
 char szSerial[64];
 int  iCheck;
 long lDate;

 if (CheckSerial())
 {

  printf("Valid license ");

  if (lDate = GetLicenseDate())
     printf("until %s",ctime(&lDate));
  else
     printf("n");

  exit(0);
 }
 else if (_kbhit() && _getch() == 0x1b)  // ESC
 {
  printf("Escape key detected.n");
  return(0);
 }

 printf("Invalid serial number.");

 exit(1);
}

/*
 * CheckSerial - validate serial number
 */
int CheckSerial(void)
{
    int sum = 0;
    char temp;
    char ser_str[16];
    int i;

    printf("Enter serial number: ");

    for (i = 0; i < 16; ++i)
    {
        ser_str[i] = _getch();
        putchar('*');
    }

    if (ValidateLicenseCode(ser_str))
    {
        for (i = 0 ; i < 16; i++)
        {
            temp = toupper(ser_str[i]);
            if (temp < '0' || temp > 'F' || (temp > '9' && temp < 'A'))
                return (0);

            if (temp <= '9')
                sum += (temp - '0') * (17 - i);
            else
                sum += (temp - 'A' + 10) * (17 - i);
        }
        return (sum % 17 == 0);
    }

    return 0;
}

以上是Keil5注册机验证码处理的示例代码,直接调用ValidateLicenseCode()函数处理验证码即可。

四、Keil5注册机的常见问题及其解决办法

1、注册码失效的解决办法:重新生成注册码,使用芯片烧录器重新注册即可。

2、无法找到芯片烧录器的解决办法:检查芯片烧录器是否连接正常,是否有驱动程序。

3、Keil5打开后无法使用的解决办法:检查是否已经成功注册,是否开启了一个有效的许可证。

五、总结

通过以上对Keil5注册机的详细讲解,相信您已经对Keil5的注册机有了更深入的了解。Keil5注册机在芯片烧录器的支持下,为我们提供了一种简便快捷的注册方式,让我们可以在更多的嵌入式开发项目中使用Keil5。

Published by

风君子

独自遨游何稽首 揭天掀地慰生平