与 dogprotect / linux-build 分支同一次改名,等价内容:
- 产品名/展示串、SDK 与运行时导出 API、.NET 命名空间全部换为 DogProtect
- 文件名与目录改名(dogprotect.sln / DogProtect/ / DogProtectCon/ / sdk/DogProtect.SDK/ /
sdk/DogProtectSDK.{h,pas,bas,inc} / runtime/DogProtect.Runtime/ / core/dogprotect.rc /
app/dogprotect_gui.app)
- 项目文件扩展名 .vmp → .dog;VM 代码节名默认 .dog(产物节 .dog0/.dog1/...)
- 授权数据/配置: DogProtect.dat、DogProtectLicense.ini、Global\\DogProtect.dat
- 域名占位 dogprotect.example、bundle id com.dogprotect.dogprotect
- 保留 VMP_* 内部宏与 third-party/
76 lines
3.5 KiB
HTML
76 lines
3.5 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<link rel="Stylesheet" type="text/css" href=
|
|
"../../default.css" />
|
|
<meta http-equiv="Content-Type" content=
|
|
"text/html; charset=utf-8" />
|
|
|
|
<title>Step 1.3: Retrieving serial number status flags</title>
|
|
</head>
|
|
|
|
<body>
|
|
<h1>Step 1.3: Retrieving serial number status flags</h1><strong>A handy function to print flags</strong>
|
|
|
|
<p>First of all, we need a handy function to transform numeric values of flags to comprehensible statuses of a serial number. Here is the code of this function:</p>
|
|
<pre class="code">#define PRINT_HELPER(state, flag) if (state & flag) printf("%s ", #flag)
|
|
void print_state(INT state)
|
|
{
|
|
if (state == 0)
|
|
{
|
|
printf("state = 0\n");
|
|
return;
|
|
}
|
|
|
|
printf("state = ");
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_CORRUPTED);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_INVALID);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_BLACKLISTED);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_DATE_EXPIRED);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_RUNNING_TIME_OVER);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_BAD_HWID);
|
|
PRINT_HELPER(state, SERIAL_STATE_FLAG_MAX_BUILD_EXPIRED);
|
|
printf("\n");
|
|
}
|
|
</pre>
|
|
|
|
<p>Despite the size, function is really simple - checks all bit flags one by one and print all that are present in the status variable. Replace
|
|
<strong>printf</strong> in the code after checking the serial number to the call to
|
|
<strong>print_state</strong>, and make changes to the serial number we pass to the licensing system:</p>
|
|
<pre class="code">char *serial = "Xserialnumber1"; // we set the serial number directly in the code, for simplicity
|
|
int res = DogProtectSetSerialNumber(serial);
|
|
print_state(res);
|
|
</pre>
|
|
|
|
<p>Now, if we run this program, the following message will be printed to the console:</p>
|
|
<pre class="code">state = SERIAL_STATE_FLAG_INVALID
|
|
please register!
|
|
</pre>
|
|
|
|
<p>Now, we put the old key back by removing "1" and run the program again:</p>
|
|
<pre class="code">state = 0
|
|
We are registered.
|
|
</pre>
|
|
|
|
<p>Now, as we can see status flags of a serial number, let's move to retrieving flags and data from a serial number.</p><strong>Retrieving serial number status</strong>
|
|
|
|
<p>You can get the status of a serial number in three ways: by calling
|
|
<strong>DogProtectSetSerialNumber()</strong>, by calling
|
|
<strong>DogProtectGetSerialNumberState()</strong> or by calling
|
|
<strong>DogProtectGetSerialNumberData()</strong> - status flags are put into one of fields of the structure. Each method is intended to use in specific time. The first check of the serial number is performed during installation. At this moment you should decline incorrect numbers, expired numbers, numbers in the black list and so on. Some limitations, for example, the maximum operation time of the program or serial number expiration date should also be checked in run-time. And the <strong>DogProtectGetSerialNumberState()</strong> method is the fastest and the most convenient way here. And if you need to receive complete information about the serial number, you can use the more powerful
|
|
<strong>DogProtectGetSerialNumberData()</strong> function.</p><br />
|
|
<a href="step14_name.htm">Next step</a>
|
|
<br />
|
|
<br />
|
|
<br />
|
|
<br />
|
|
<hr noshade="noshade" size="1" />
|
|
|
|
<div align="center">
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|