//
// TESTCOMMANDS 2 - Shows use of core data in TPC DLL
//
// Extra Includes
#include "stdio.h"
// My Own Include
#include "TESTCOMMANDS.h"
// Include Core (optional)
#include "globstruct.h"
GlobStruct* g_pGlob = NULL;
//
// Constructors (optional)
//
MYCOMMAND void Constructor ( void )
{
// Create memory here
}
MYCOMMAND void Destructor ( void )
{
// Free memory here
}
MYCOMMAND void ReceiveCoreDataPtr ( LPVOID pCore )
{
// Get Core Data Pointer here
g_pGlob = (GlobStruct*)pCore;
}
//
// Standard DLL Main
//
MYCOMMAND BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
//
// Simple Commands (core not needed)
//
MYCOMMAND void PrintText( LPSTR pString )
{
if (!g_pGlob) MessageBox(0, "Core not set", "", MB_OK);
if(pString)
{
MessageBox(NULL, pString, "", MB_OK);
}
}
MYCOMMAND int GetValue( void )
{
return 42;
}
//
// String Commands (core needed)
//
MYCOMMAND DWORD ReturnAFloat( int iValue )
{
float fValue = ((float)iValue) + 0.1f;
return *(DWORD*)&fValue;
}
MYCOMMAND DWORD ReverseString( DWORD pOldString, DWORD pStringIn )
{
if (!g_pGlob) MessageBox(0, "Core not set", "", MB_OK);
// Delete old string
if(pOldString) g_pGlob->CreateDeleteString ( (DWORD*)&pOldString, 0 );
// Return string pointer
LPSTR pReturnString=NULL;
// If input string valid
if(pStringIn)
{
// Create a new string and copy input string to it
DWORD dwSize=strlen( (LPSTR)pStringIn );
g_pGlob->CreateDeleteString ( (DWORD*)&pReturnString, dwSize+1 );
strcpy(pReturnString, (LPSTR)pStringIn);
// Reverse the new string
strrev(pReturnString);
}
// Return new string pointer
return (DWORD)pReturnString;
}
MYCOMMAND void DisplayLargeNumbers( double dValueA, LONGLONG lValueB )
{
// Make output
LPSTR pOutput = new char[256];
sprintf(pOutput, "Output - Double Float:%.16g Double Integer:%I64d", dValueA, lValueB);
// Use Core PRINT to display output
g_pGlob->PrintStringFunction ( pOutput, true );
// Free output string
if(pOutput)
{
delete pOutput;
pOutput=NULL;
}
}
/
// Header File
//
// Common Includes
#include "windows.h"
// Define macro
#define MYCOMMAND __declspec ( dllexport )
// Constructor Functions (optional)
MYCOMMAND void Constructor ( void );
MYCOMMAND void Destructor ( void );
MYCOMMAND void ReceiveCoreDataPtr ( LPVOID pCore );
// Do not decorate DLL-function-names
extern "C"
{
// My Commands and Functions
MYCOMMAND void PrintText ( LPSTR pString );
MYCOMMAND int GetValue ( void );
MYCOMMAND DWORD ReturnAFloat ( int iValue );
MYCOMMAND DWORD ReverseString ( DWORD pOldString, DWORD pStringIn );
MYCOMMAND void DisplayLargeNumbers ( double dValueA, LONGLONG lValueB );
}