The following illustrates the steps needed to set network protection in an application program and how to unlock that protection. For this explanation, we are using the network protection sample program that is included with the ProtectKit3.5.

Step1: Set protection

Using the Set Network Protection Tool (Pr3SetProtectNet.exe), set the NetWord into the sample program exe (Project1.exe)

Step2: Copy to network

In multiple client PCs connected on a LAN network, copy the sample program exe (Project1.exe) and the Pkitnet32(64).dll.

Step3: Start Application

Enter a message and time (in seconds), then click the Initialize button and then the Start button. Information (message, PC Name, and Network Card) will be transmitted between the applications running on the LAN network. This means that the application is being used by multiple PCs on the LAN network.

Step4: Set Application ID:

Only programs that have the same application id can communicate with each other. In this sample we set application ids according to the programming language

CBuilder6

     PROTECTKIT3NET net;
     StrCopy(net.szAppID, "12345678.BCB");     // Sets the unique application id

Delphi6

     var
          net: PROTECTKIT3NET;
     begin
          StrPCopy(net.szAppID, '12345678.DEL');     // Sets the unique application id

VB6

     Dim net As PROTECTKIT3NET
     net.szAppID = "12345678.VB6" & Chr$(0)     ' Sets the unique application id

VC6

     PROTECTKIT3NET net;
     lstrcpy(net.szAppID, "12345678.VC6");     // Sets the unique application id

Renaming the PkitNet32(64).dll

It is recommended that you rename the PkitNet32(64).dll to increase security.

Using the PkitNet64.dll

This DLL file is to be used with 64 bit application programs. Even on a 64 bit Windows operating system, if your application program is a 32 bit application, you must use the PkitNet32.dll.

Checking for multiple instances of the application running on the same machine.

The ProtectKit3.5 network protection checks applications running on different machines on a LAN network by transmitting and receiving messages between these machines. What happens if there are multiple instances of the application running on one of the machines on this network?

Basically, the ProtectKit3.5 network protection does not check for multiple instances of an application running on the same machine. The PK3NETStartNet() function will succeed for the first instance and that application will communicate with the other applications on the network. For the second instance (and other instances) running on that machine, the PK3NETStartNet() function will fail. A problem can arise when the first instance closes. This is the instance that was communicating with the other applications on the network.

To resolve this potential pitfall of multiple instances of the application running on the same machine, you simply call the PK3NETStartNet function inside a Timer event. This will periodically initialize the network check. If the first instance of the application closes, the second instance will be initialized when the timer event calls the PK3NETStartNet function and your network protection will not be compromised.

Below is the code that we used in this sample that illustrates this.

In CBuilder6

     if (PK3NETStartNet() == true)
          NetStartFlag = true;
     else
     if (PK3NETGetError() == 1004)
          Timer1->Enabled = true;

     void __fastcall TForm1::Timer1Timer(TObject *Sender)
     {
          // Starts network check
          if (NetStartFlag == false)
               NetStartFlag = PK3NETStartNet();

          if (NetStartFlag == true)
               Timer1->Enabled = false;
     }

In Delphi6

     if PK3NETStartNet = true then
      begin
          NetStartFlag := true;
     end else begin
          if PK3NETGetError = 1004 then
               Timer1.Enabled := True;
     end;

     procedure TForm1.Timer1Timer(Sender: TObject);
     begin
          // Starts network check
          if NetStartFlag = false then
               NetStartFlag := PK3NETStartNet;

          if NetStartFlag = true then
               Timer1.Enabled := false;
     end;

In VB6

     ret = PK3NETStartNet
     If ret = True Then
          NetStartFlag = True
     Else
          If PK3NETGetError = 1004 Then
               Timer1.Enabled = True
          End If
     End If

     Private Sub Timer1_Timer()
          ' Starts network check
          If NetStartFlag = False Then
               NetStartFlag = PK3NETStartNet
          End If
          If NetStartFlag = True Then
               Timer1.Enabled = False
          End If
     End Sub

In VC6

     if (PK3NETStartNet() == TRUE) {
          NetStartFlag = TRUE;
     } else {
          if (PK3NETGetError() == 1004) {
               SetTimer(1, 10000, NULL);     // 10 second interval
          }
     }

     void CProject1Dlg::OnTimer(UINT nIDEvent)
     {
          // Starts network check
          if (NetStartFlag == FALSE)
               NetStartFlag = PK3NETStartNet();

          if (NetStartFlag == TRUE) {
               KillTimer(1);
          }
     }