Originally Posted by
crazybucky
Any examples? Sorry to be suck a pain!
The DLL
Code:
// myDLL.cpp
// Compile: cl.exe /LD myDLL.cpp
#include <string.h>
#define DECLARE_EXPORT __declspec(dllexport)
extern "C"
{
DECLARE_EXPORT void myFunction( char* pIn, unsigned char * pOut )
{
int v, vlen;
vlen = strlen(pIn);
for(v = 0; v < vlen; v++)
pOut[v] = pIn[v] + 1;
}
}
The calling code
Code:
// Example of explicit linking of DLL
#include <windows.h>
#include <stdio.h>
// Function pointer
typedef void (*myFunction)(char *, unsigned char *);
int main(void)
{
myFunction _myFunction;
char cInput[] = {"AS0100012178 2178"};
unsigned char ucReturn[24] = {0};
int iIndex;
HINSTANCE hInstLibrary = LoadLibrary("myDLL.dll");
if (hInstLibrary)
{
_myFunction = (myFunction)GetProcAddress(hInstLibrary, "myFunction");
if (_myFunction)
{
_myFunction(cInput, ucReturn);
for(iIndex = 0; iIndex < strlen(cInput); iIndex++)
printf("%c %c 0x%02X\n", cInput[iIndex], ucReturn[iIndex],ucReturn[iIndex]);
}
else printf("_myFunction failed to initialize\n");
FreeLibrary(hInstLibrary);
}
else printf("myDLL.dll failed To Load!\n");
return 0;
}