Пример #1
0
// ReadKey():
//  Finds and reads a FreeKey license, returning false if the
//   key cannot be found.  Returns a pointer to the matching
//   key if the found; otherwise, it returns NULL.
const char * FreeKeyDongle::ReadKey( const char *path ) {
  char filename[ MAX_PATH_LENGTH ];

  if( path == NULL ) {
    // Get the Plug-in's Path
    #ifdef WIN32
      GetModuleFileName( hinst, filename, MAX_PATH_LENGTH );
    #endif
    DirStrings::ChangeFile( filename, "freekey.key" );
  } else
    strcpy( filename, path );

  if( !DirInfo::Exists( filename ) )
    return NULL;

  pifstream in( filename );
  if( !in )
    return NULL;

  in.GuessEOLType();
  static char buffer[ 64 ];
  do {
    in.getline( buffer, 64 );
    if( TestKey( buffer, GetDongleID() ) )
      return buffer;
  } while( !in.eof() );

  return NULL;
}
Пример #2
0
// MakeRegisterPanel():
//  Creates the Register Panel
bool SimplifyDongle::MakeRegisterPanel() {
  if( simp_int == NULL )
    return false;

  // Create the Panel
  register_panel = simp_int->panel_funcs->Create( "Simplify Registration" );

  try {
    if( !( dongle_id = STRRO_CTL( simp_int->panel_funcs->orig_struct, register_panel,
                                  "Dongle ID", 43 ) ) )
      throw false;

    if( !( reg_code = STR_CTL( simp_int->panel_funcs->orig_struct, register_panel,
                               "Reg Code", 43 ) ) )
      throw false;

    if( !( register_now = WBUTTON_CTL( simp_int->panel_funcs->orig_struct, register_panel,
                                       "Register Now", 150 ) ) )
      throw false;

    // Position some things
    MOVE_CON( dongle_id, 25, 212 );
    PanelTools::AlignLabels( dongle_id, reg_code );

    PAN_SETW( simp_int->panel_funcs->orig_struct, register_panel, 400 );
    PAN_SETH( simp_int->panel_funcs->orig_struct, register_panel, 350 );

    PanelTools::PutUnder( reg_code, register_now );

    int pw = PAN_GETW( simp_int->panel_funcs->orig_struct, register_panel );
    int w  = CON_W( register_now );
    int y  = CON_Y( register_now );
    MOVE_CON( register_now, (pw/2 - w/2), y );

    // Default Values
    char buffer[10];
    sprintf( buffer, "%ld", GetDongleID() );
    SET_STR( dongle_id, buffer, strlen( buffer ) );

    // Listener Functions
    CON_SETEVENT( register_now, OnRegisterNow, this );
    CON_SETEVENT( reg_code,     OnRegisterNow, this );

    // Set the Draw Functions
    simp_int->panel_funcs->Set( register_panel, PAN_USERDRAW, DrawRegisterPanel );

    return true;
  } catch( bool a ) {
    if( !a ) {
      simp_int->message->Error("Error creating interface controls; aborting" );
      return false;
    }
  }

  return true;
}