title: Getting a HASP key with C/C++ (Problem)
body: <p>I seem to be in need of some help (and by some, I mean a lot).</p>
  
  <p>Im trying to make a C program (or c++ if I get it to work, the language is not really important) to connect to a HASP USB. HASP is basically a USB drive that has some unique codes. The purpose of the HASP is to basically just "secure" another program, so that it only runs while the HASP is connected to the computer.</p>
  
  <p>First of all, let me say that I am actually trying to get it to work, not hacking another one. I am using the demo key for development, for now, although I have a master key.</p>
  
  <p>This HASP program features a toolbox, that should generate the code in C ready to copy paste and get it to work. But, it doesent actually work, or at least, its not just copy paste.</p>
  
  <p>(For more information about HASP, go <a href="http://www2.safenet-inc.com/google/SRM/dk-hasp.asp?CID=GooIntl-IND&amp;HBX_PK=hasp&amp;HBX_OU=50&amp;CMP=KNC-GoogleAdd&amp;wcw=google&amp;_kk=hasp&amp;_kt=e9b07d11-6db3-4153-a46b-5dc95204b6a3&amp;gclid=CJfxibrp-qUCFRQv3wodBnwfpA" rel="nofollow">http://www2.safenet-inc.com/google/SRM/dk-hasp.asp?CID=GooIntl-IND&amp;HBX_PK=hasp&amp;HBX_OU=50&amp;CMP=KNC-GoogleAdd&amp;wcw=google&amp;_kk=hasp&amp;_kt=e9b07d11-6db3-4153-a46b-5dc95204b6a3&amp;gclid=CJfxibrp-qUCFRQv3wodBnwfpA</a> )</p>
  
  <p>Unfortunately, I do NOT have any kind of C or C++ coding experience, so I am having several problems trying to work this out. I only programmed the other part in Director (similar to Flash).</p>
  
  <p>The code it gives me just for making a login (read, connection) to the HASP is the following:</p>
  
  <pre><code>const hasp_feature_t feature = HASP_DEFAULT_FID;
  
  hasp_handle_t handle = HASP_INVALID_HANDLE_VALUE;
  hasp_status_t status;
  
  
  //This is a code needed to login, its just the demo code for now, but it matches
  //the HASP i'm using
  
  unsigned char vendor_code[] =
  
  "AzIceaqfA1hX5wS+M8cGnYh5ceevUnOZIzJBbXFD6dgf3tBkb9cvUF/Tkd/iKu2fsg9wAysYKw7RMAsV"
  "vIp4KcXle/v1RaXrLVnNBJ2H2DmrbUMOZbQUFXe698qmJsqNpLXRA367xpZ54i8kC5DTXwDhfxWTOZrB"
  "rh5sRKHcoVLumztIQjgWh37AzmSd1bLOfUGI0xjAL9zJWO3fRaeB0NS2KlmoKaVT5Y04zZEc06waU2r6"
  "AU2Dc4uipJqJmObqKM+tfNKAS0rZr5IudRiC7pUwnmtaHRe5fgSI8M7yvypvm+13Wm4Gwd4VnYiZvSxf"
  "8ImN3ZOG9wEzfyMIlH2+rKPUVHI+igsqla0Wd9m7ZUR9vFotj1uYV0OzG7hX0+huN2E/IdgLDjbiapj1"
  "e2fKHrMmGFaIvI6xzzJIQJF9GiRZ7+0jNFLKSyzX/K3JAyFrIPObfwM+y+zAgE1sWcZ1YnuBhICyRHBh"
  "aJDKIZL8MywrEfB2yF+R3k9wFG1oN48gSLyfrfEKuB/qgNp+BeTruWUk0AwRE9XVMUuRbjpxa4YA67SK"
  "unFEgFGgUfHBeHJTivvUl0u4Dki1UKAT973P+nXy2O0u239If/kRpNUVhMg8kpk7s8i6Arp7l/705/bL"
  "Cx4kN5hHHSXIqkiG9tHdeNV8VYo5+72hgaCx3/uVoVLmtvxbOIvo120uTJbuLVTvT8KtsOlb3DxwUrwL"
  "zaEMoAQAFk6Q9bNipHxfkRQER4kR7IYTMzSoW5mxh3H9O8Ge5BqVeYMEW36q9wnOYfxOLNw6yQMf8f9s"
  "JN4KhZty02xm707S7VEfJJ1KNq7b5pP/3RjE0IKtB2gE6vAPRvRLzEohu0m7q1aUp8wAvSiqjZy7FLaT"
  "tLEApXYvLvz6PEJdj4TegCZugj7c8bIOEqLXmloZ6EgVnjQ7/ttys7VFITB3mazzFiyQuKf4J6+b/a/Y";
  
  status = hasp_login(feature, vendor_code, &amp;handle);
  
  /* check if operation was successful */
  if (status != HASP_STATUS_OK)
  {
      switch (status)
      {
          case HASP_FEATURE_NOT_FOUND:
              break;
          case HASP_HASP_NOT_FOUND:
              break;
          case HASP_OLD_DRIVER:
              break;
          case HASP_NO_DRIVER:
              break;
          case HASP_INV_VCODE:
              break;
          case HASP_FEATURE_TYPE_NOT_IMPL:
              break;
          case HASP_TMOF:
              break;
          case HASP_TS_DETECTED:
              break;
          default:
              break;
      }
  }
  </code></pre>
  
  <p>And the error:</p>
  
  <pre><code>hasp_demo.cpp|44|error: expected constructor, destructor, or type conversion before '=' token|
  hasp_demo.cpp|47|error: expected unqualified-id before 'if'|
  ||=== Build finished: 2 errors, 0 warnings ===|
  </code></pre>
  
  <p>I know this is a very specific help request, but I'm completely lost now and don't know what to do from now on. I tried playing around with the code, but it always gets me errors.</p>
  
  <p>Also, im on windows, using GNU GCC Compiler in Codeblocks IDE.</p>