trial.cpp
上传用户:graphite
上传日期:2020-09-09
资源大小:2587k
文件大小:5k
源码类别:

破解

开发平台:

Others

  1. // trial.cpp : Defines the entry point for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #include <shellapi.h>
  6. #include "include/aspr_api.h"
  7. #include "include/asprotect.h"
  8. #pragma comment(lib,"include/aspr_ide.lib")
  9. #define MAX_LOADSTRING 100
  10. char* UserKey = NULL;
  11. char* UserName = NULL;
  12. char* LocalHardwareID = NULL;
  13. char* ModeName = NULL;
  14. DWORD TrialDaysTotal = 0,
  15. TrialDaysLeft = 0;
  16. //---------------------------------------------------------------------
  17. BOOL APIENTRY RegDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  18. {
  19. char keybuf[1024];
  20. char namebuf[1024];
  21. char buffer[1024];
  22. int size;
  23. switch (msg) {
  24. case WM_INITDIALOG:
  25. LocalHardwareID = GetHardwareID();
  26. SetDlgItemText(hwnd, IDC_HARDWAREKEY_EDIT, LocalHardwareID);
  27. return TRUE;
  28.         case WM_COMMAND:
  29.             switch (LOWORD(wParam)) {
  30. case IDOK:
  31. // key
  32. size = GetDlgItemText(hwnd, IDC_REGKEY_EDIT, keybuf, 1024);
  33. keybuf[size] = 0;
  34. // name
  35. size = GetDlgItemText(hwnd, IDC_REGNAME_EDIT, namebuf, 1024);
  36. namebuf[size] = 0;
  37. if ( CheckKeyAndDecrypt( (char*)keybuf, (char*)namebuf, TRUE ) == TRUE )
  38. {
  39. MessageBox(hwnd, "Thank you for your registration!", "Registration", MB_ICONINFORMATION);
  40.                 EndDialog(hwnd, IDOK);
  41.                     break;
  42. }
  43. else
  44. {
  45. MessageBox(hwnd, "Key is not valid, please contact manufacture!","Registration", MB_ICONWARNING);
  46.                     break;
  47. }
  48. case IDC_SEND:
  49. buffer[0] = 0;
  50. lstrcat(buffer,"mailto:support@aspack.com?subject=Hardware%20ID%20for%20Advanced%20Application%201.0&body=Hardware%20ID is%20:%20");
  51. lstrcat(buffer,LocalHardwareID);
  52. lstrcat(buffer,"%0d%0aRegistration%20information%20:");
  53.                     ShellExecute((HWND)GetDesktopWindow(), "open", buffer, NULL, NULL, SW_SHOWNORMAL);
  54.                     break;
  55.                 case IDCANCEL:
  56.                     EndDialog(hwnd, IDCANCEL);
  57.                     break;
  58.             }
  59.             break;
  60.     }
  61.     return FALSE;
  62. }
  63. //---------------------------------------------------------------------
  64. void ProcessRegistration( HWND hwnd )
  65. {
  66.   char caption[100];
  67.   char buffer[256];
  68.   MODE_STATUS   mode_status;
  69.   GetRegistrationInformation( 0, &UserKey,  &UserName );
  70.   if ((UserKey != NULL) && (strlen(UserKey) > 0))
  71.   {
  72. // Trial doesn't expire
  73. // Application was registered
  74. REG_CRYPT_BEGIN1
  75. // caption
  76. strcpy( caption, "Registered version!" );
  77. SetWindowText( hwnd, caption );
  78.     GetModeInformation( 0, &ModeName, &mode_status );
  79. // exit -> close
  80. SetWindowText( GetDlgItem(hwnd,IDCANCEL), "Close" );
  81. // hide trial buttons
  82. ShowWindow(GetDlgItem(hwnd,IDC_BUYNOW), SW_HIDE);
  83. ShowWindow(GetDlgItem(hwnd,IDC_REG_BUTTON), SW_HIDE);
  84. // registered info
  85. wsprintf( buffer,"Key: %snName: tt%snMode Name: t%s",
  86.   UserKey, UserName, ModeName );
  87. SetDlgItemText(hwnd, IDC_TEXT, buffer);
  88. REG_CRYPT_END1
  89.   }
  90.   else
  91.   {
  92. if (GetTrialDays( 0, &TrialDaysTotal, &TrialDaysLeft ))
  93. {
  94. // caption
  95. strcpy( caption, "TRIAL version!" );
  96. SetWindowText( hwnd, caption );
  97. // show trial buttons
  98. ShowWindow(GetDlgItem(hwnd,IDC_BUYNOW), SW_SHOW);
  99. ShowWindow(GetDlgItem(hwnd,IDC_REG_BUTTON), SW_SHOW);
  100. // trial info
  101. if (TrialDaysLeft == 0)
  102. {
  103. strcpy( buffer, "ttTRIAL EXPIRED!" );
  104. SetDlgItemText(hwnd, IDC_TEXT, buffer);
  105. }
  106. else
  107. {
  108. wsprintf( buffer,"tUnregistered trial version:nntYou have : %d day(s) left",
  109.   TrialDaysLeft );
  110. SetDlgItemText(hwnd, IDC_TEXT, buffer);
  111. }
  112. }
  113.   }
  114. }
  115. //---------------------------------------------------------------------
  116. BOOL APIENTRY DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  117. {
  118. switch (msg) {
  119. // Init
  120. case WM_INITDIALOG:
  121. ProcessRegistration( hwnd );
  122. return TRUE;
  123. // Cmd
  124.         case WM_COMMAND:
  125.  
  126. switch (LOWORD(wParam)) {
  127. case IDC_REG_BUTTON:
  128. ShowWindow(hwnd, SW_HIDE);
  129. DialogBox( NULL,(LPSTR)MAKEINTRESOURCE(IDD_REG_DIALOG),hwnd,(DLGPROC/*WNDPROC*/)RegDlgProc);
  130. ProcessRegistration( hwnd );
  131. ShowWindow(hwnd, SW_SHOW);
  132. break;
  133. case IDC_BUYNOW:
  134. ShellExecute((HWND)GetDesktopWindow(), "open", "http://www.aspack.com/register.htm", NULL, NULL, SW_SHOWNORMAL);
  135. break;
  136.                 case IDOK:
  137.                     EndDialog(hwnd, IDOK);
  138.                     break;
  139.                 case IDCANCEL:
  140.                     EndDialog(hwnd, IDCANCEL);
  141.                     break;
  142.             }
  143.             break;
  144.     }
  145.     return FALSE;
  146. }
  147. //---------------------------------------------------------------------
  148. int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
  149.                     PSTR szCmdLine, int iCmdShow){
  150.     MessageBox( 0, "This example shows the work in trial mode.", "Information", MB_ICONINFORMATION );
  151. DialogBox(NULL,(LPSTR)MAKEINTRESOURCE(IDD_DIALOG),NULL,(DLGPROC/*WNDPROC*/)DlgProc);
  152. return 0;
  153. }