Accessing API through DLL Interface
This section describes the syntax of the exported functions in the gcdapi.dll library. The DLL API consists of 8 functions: 6 from the Device API and 2 (gcdapi_Load and gcdapi_Unload) are exclusive of "Direct Interface", utilized to initiate/close the interface.
Direct Interface Functions:
Example and Template:
![]() |
Don't forget to define GCAPI_DIRECT before include the gppapi.h header.
#define GCAPI_DIRECT
#include "gcapi.h"
|
1. gcdapi_Load
Must be called after load the gcdapi.dll library.
Prototype:
uint8_t _stdcall gcdapi_Load ( )
Parameters:
None
Return:
1 for success and 0 for error
Example:
if(!gcdapi_Load()) {
// Error
}
|
2. gcdapi_Unload
Must be called before unload the gcdapi.dll library.
Prototype:
void _stdcall gcdapi_Unload ( )
Parameters:
None
Return:
None
Example:
gcdapi_Unload();
|
Example Code for Direct Interface
#include <windows.h>
#define GCAPI_DIRECT
#include "gcapi.h"
GCDAPI_Load gcdapi_Load = NULL;
GCDAPI_Unload gcdapi_Unload = NULL;
GCAPI_IsConnected gcapi_IsConnected = NULL;
GCAPI_GetFWVer gcapi_GetFWVer = NULL;
GCAPI_Read gcapi_Read = NULL;
GCAPI_Write gcapi_Write = NULL;
GCAPI_GetTimeVal gcapi_GetTimeVal = NULL;
GCAPI_CalcPressTime gcapi_CalcPressTime = NULL;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, lpCmdLine, int nShowCmd) {
HINSTANCE hInsGC = NULL;
GCAPI_REPORT report = {0};
int8_t output[GCAPI_OUTPUT_TOTAL] = {0};
hInsGC = LoadLibrary(TEXT("gcdapi.dll"));
if(hInsGC == NULL) {
return(1);
}
gcdapi_Load = (GCDAPI_Load) GetProcAddress(hInsGC, "gcdapi_Load");
gcdapi_Unload = (GCDAPI_Unload) GetProcAddress(hInsGC, "gcdapi_Unload");
gcapi_IsConnected = (GCAPI_IsConnected) GetProcAddress(hInsGC, "gcapi_IsConnected");
gcapi_GetFWVer = (GCAPI_GetFWVer) GetProcAddress(hInsGC, "gcapi_GetFWVer");
gcapi_Read = (GCAPI_Read) GetProcAddress(hInsGC, "gcapi_Read");
gcapi_Write = (GCAPI_Write) GetProcAddress(hInsGC, "gcapi_Write");
gcapi_GetTimeVal = (GCAPI_GetTimeVal) GetProcAddress(hInsGC, "gcapi_GetTimeVal");
gcapi_CalcPressTime = (GCAPI_CalcPressTime) GetProcAddress(hInsGC, "gcapi_CalcPressTime");
if(gcdapi_Load == NULL || gcdapi_Unload == NULL || gcapi_IsConnected == NULL || gcapi_GetFWVer == NULL || gcapi_Read == NULL || gcapi_Write == NULL || gcapi_GetTimeVal == NULL || gcapi_CalcPressTime == NULL) {
FreeLibrary(hInsGC);
return(1);
}
if(!gcdapi_Load()) {
FreeLibrary(hInsGC);
return(1);
}
if(gcapi_IsConnected()) {
gcapi_Read(&report);
for(uint8_t i=0; i<GCAPI_INPUT_TOTAL; i++) {
output[i] = report.input[i].value;
}
gcapi_Write(output);
}
gcdapi_Unload();
FreeLibrary(hInsGC);
return(0);
}
|
Direct Interface Template
You can use the direct API template to create the basic project container and a preliminary setups for your application. Unzip and open the "Direct API Template.sln" with Visual C++ 2010 (or newer).
• Download: Direct API Template