Passwort vergessen? Registrieren
Example in C++

This is an example how to use the tagReader.dll with C++

Loading the DLL:

First you need to load the library, using the LoadLibrary function provided by the <windows.h>. This then looks something like:

HMODULE handle = LoadLibrary(TEXT("C:\\Users\\example\\Documents\\tagReaderDLL\\tagReader.dll"));

If the handle holds a value other than NULL, the library was succesfully loaded.

Loading a function:

To use a function provided by the DLL you first need to define it. Therefore you need the return value and the parameters of the function.

An example to call the function "NewTagReader", which returns an integer and uses two integer parameters, looks like:

typedef int(NEWTAGREADERFUNC)(int, int);

To load the function, GetProcAddress is used. It requires the handle and the name of the function you want to load (Note: the function name is case sensitive). this may looks like:

NEWTAGREADERFUNC *pNEWTAGREADERFUNC = (NEWTAGREADERFUNC *)::GetProcAddress(handle, "NewTagReader");

If the value of pNEWTAGREADERFUNC is other than NULL, the function was loaded successfully.

Calling a function:

After loading a function, the function is ready to be called. This may looks like:

tagReaderID = (*pNEWTAGREADERFUNC)(0xe6a,0x350);

A full example to connect to the TagReader and make it beep:

#include <windows.h>
#include <iostream>

using namespace std;

typedef int(NEWTAGREADERFUNC)(int, int);
typedef int(CONNECTFUNC)(int);
typedef int(DOREADERACTIONFUNC)(int, int);
typedef int(GETCHIPIDFUNC)(int);

int main(int argc, char **argv)
{

   HMODULE handle = LoadLibrary(TEXT("C:\\Users\\example\\Documents\\project\\tagReader.dll"));

   if (NULL == handle)
   {
      cout << "Could not load library" << endl;
      return -1;
   }

   NEWTAGREADERFUNC *pNEWTAGREADERFUNC = (NEWTAGREADERFUNC *)::GetProcAddress(handle, "NewTagReader");
   int tagReaderID;

   if (pNEWTAGREADERFUNC)
   {
      tagReaderID = (*pNEWTAGREADERFUNC)(0xe6a, 0x350);
      cout << tagReaderID << endl;
   }
   else
   {
      return -1;
   }

   CONNECTFUNC *pCONNECTFUNC = (CONNECTFUNC *)::GetProcAddress(handle, "TRConnect");
   int connect;

   if (pCONNECTFUNC)
   {
      connect = (*pCONNECTFUNC)(tagReaderID);
      cout << "successfully connected: " << connect << endl;
   }

   DOREADERACTIONFUNC *pDOREADERACTIONFUNC = (DOREADERACTIONFUNC *)::GetProcAddress(handle, "TRDoReaderAction");
   int actionResult;

   if (pDOREADERACTIONFUNC) {
      actionResult = (*pDOREADERACTIONFUNC)(tagReaderID, 7);
      cout << "actionResult is: " << actionResult << endl;
   }

   GETCHIPIDFUNC *pGETCHIPIDFUNC = (GETCHIPIDFUNC *)::GetProcAddress(handle, "TRGetChipID");

   if (pGETCHIPIDFUNC) {
      char *chipID = (*pSENDCOMMANDFUNC)(tagReaderID);
      cout << "chipID is: " << chipID << endl;
   }

   return 0;
}

 

×

Haben Sie eine Frage?

Unser Team berät Sie gern persönlich.

Schreiben Sie uns!

Das Team von RACE RESULT berät Sie gerne zu Ihren individuellen Bedürfnissen, behebt bestehende Probleme und beantwortet Ihre Fragen. Kontaktieren Sie uns jetzt über das Formular.

Wenn Sie eine Support-Frage haben, fügen Sie bitte Ihre Event-ID hinzu!

Ich habe die Datenschutzbestimmungen gelesen.