<h1>Step 1.9: Hardware lock</h1><strong>Receiving a hardware identifier</strong>
<p>Before we lock to hardware, we must receive a hardware identifier. The identifier is put into a serial number, and when the number is passed to the licensing system, it checks if identifiers match. So, first we need to receive the identifier of our hardware. Let's reduce the
<strong>main()</strong> function to the bare minimum:</p>
<p>To lock our test serial number to hardware, we should add one more line to the ini-file. This time we define the identifier that is "put into" the serial number:</p>
<preclass="code">KeyHWID=test
</pre>
<p>Then we complicate <strong>main()</strong> back a bit. Now it will pass a serial number and analyze the result it gets:</p>
<p>Now let's try to "run" our program on another hardware. We simply change the value of the MyHWID parameter in the ini-file from "test" to "new test". Run the program again:</p>
<preclass="code">HWID: new test
state = SERIAL_STATE_FLAG_BAD_HWID
</pre>
<p>This time the licensing system returned the
SERIAL_STATE_FLAG_BAD_HWID flag, which means the real hardware identifier and the one stored in the serial number are not matching. The current identifier we see on the screen is "new test", while the serial number holds "test". If we change the KeyHWID parameter in the ini-file to "new test" we can make our serial number work on this "hardware" too.</p><br/>