General information
Category:
COM/DCOM and OLE Automation
Title:
Determining parameters to pass to a DLL.
Hi All
I have been sent a third party DLL to use in conjunction with some Postcoding software and as usual the documentation comes with calling examples for VB & C++ only. I have attempted to implement a call directly from VFP7 but the code keeps crashing out of VFP7 without returning any kind of error report.
Is there anyway I can determine the number and sizeof the parameters to pass to this DLL.
Many thanks
Paul
Here is the C++ code:
>>>>>>>>>>>>>>>>>>>>>
#include
#include
void msgstr(DWORD code, char *buf, int buf_l)
{
int x,y;
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
buf,buf_l,NULL);
x=y=0;
while (buf[x]) {
if (!iscntrl(buf[x])) buf[y++] = buf[x];
x++;
}
buf[y] = '\0';
}
int main(int argc, char *argv[])
{
HINSTANCE lib;
char iobuf[1024];
struct verify_s {
short count;
char more[1];
char table[250][90];
};
typedef void (__stdcall * rapidCallPtr_t)(char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[40], char (*)[5][30], struct verify_s *);
rapidCallPtr_t rapidA;
int i,l;
struct calldata_s {
char status[40];
char premise[40];
char postcode[40];
char addr1[40];
char addr2[40];
char addr3[40];
char addr4[40];
char addr5[40];
char addr6[40];
char addr7[40];
char addr8[40];
char addr9[40];
char barcode[40];
char matchkey[40];
char name32[40];
char dps[40];
char error[40];
char ref[5][30];
struct verify_s verify;
};
struct calldata_s cdata;
if (!(lib=LoadLibrary("C:\\PAF5\\LMaddman\\cob4001.dll"))) {
strcpy(iobuf,"Cannot open cob4001.dll; ");
l=strlen(iobuf);
msgstr(GetLastError(),iobuf+l,sizeof iobuf - l);
puts(iobuf);
}
else if (!(rapidA = (rapidCallPtr_t)GetProcAddress(lib,"RAPID"))) {
strcpy(iobuf,"Unable to resolve library reference rapid; ");
l=strlen(iobuf);
msgstr(GetLastError(),iobuf+l,sizeof iobuf - l);
puts(iobuf);
}
printf("%08X\n",rapidA);
memset(&cdata,' ',sizeof cdata);
cdata.verify.count = 0;
cdata.status[0] = 'R';
while (cdata.status[0] == 'R') {
strncpy(cdata.postcode,"BA1 5HH",7);
cdata.premise[0] = '5';
(rapidA)(&cdata.status, &cdata.postcode, &cdata.premise, &cdata.name32,
&cdata.addr1, &cdata.addr2, &cdata.addr3, &cdata.addr4, &cdata.addr5, &cdata.addr6,
&cdata.addr7, &cdata.addr8, &cdata.addr9, &cdata.barcode, &cdata.matchkey, &cdata.dps,
&cdata.error, &cdata.ref, &cdata.verify);
}
printf("%.*s\n",40,cdata.name32);
for (i=0;i<5;i++) printf("%.30s\n",cdata.ref[i]);
return 0;
}
>>>>>>>>>>>>>>>>>>>
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only