jimjung27
asked on
Call VB ActiveX dll from C language
The scenario is simple - a screen displays a list of data. Click an item on the list to display an scanned image. A document id is passed to determine which image to display. IBM imaging software displays the image.
Problem is: IBM imaging software uses ActiveX VB dll to display image and screen is written in J. D. Edwards which is a low level C language, so I must call the VB dll from C language. I'm using MS Studio 6. I wonder if this is possible?????
I have the following so far. When I click the screen, it goes through the program and does nothing. I have tried to debug this by adding some dll's into the Program Settings with no success. A window pops up showing the Disassembly, breakpoints are not recognized and I can't display any field values.
Any help is very much appreciated ... Jim
// code from header
#include <windows.h>
typedef (*PFNJDE2CM)( LPCSTR ); // VB dll to call receives one string parm
#ifndef DATASTRUCTURE_D550413M
#define DATASTRUCTURE_D550413M
typedef struct tagDSD550413M
{
char szDOCNAME[9]; // string parm is passed into this header
} DSD550413M, *LPDSD550413M; // and stored in this struct
#define IDERRszDOCNAME_2 1L
#endif
......
// code from .c
#define B550413M_c
#include <B550413M.h> // this is header above
{
int nResult = 0;
PFNJDE2CM lpJDE2CM;
HINSTANCE hLibrary;
hLibrary = LoadLibrary("c:\\JDE2CM.dl l.dll"); // this is VB dll
if(hLibrary != NULL)
{
// gets the address of the function inside the VB dll
lpJDE2CM = (PFNJDE2CM) GetProcAddress (hLibrary, "DllGetClassObject");
if(!lpJDE2CM)
FreeLibrary(hLibrary);
else
{
// call the VB dll function
const char *docid = 0;
docid = lpDS->szDOCNAME;
nResult = lpJDE2CM(docid);
}
}
return (ER_SUCCESS);
}
Problem is: IBM imaging software uses ActiveX VB dll to display image and screen is written in J. D. Edwards which is a low level C language, so I must call the VB dll from C language. I'm using MS Studio 6. I wonder if this is possible?????
I have the following so far. When I click the screen, it goes through the program and does nothing. I have tried to debug this by adding some dll's into the Program Settings with no success. A window pops up showing the Disassembly, breakpoints are not recognized and I can't display any field values.
Any help is very much appreciated ... Jim
// code from header
#include <windows.h>
typedef (*PFNJDE2CM)( LPCSTR ); // VB dll to call receives one string parm
#ifndef DATASTRUCTURE_D550413M
#define DATASTRUCTURE_D550413M
typedef struct tagDSD550413M
{
char szDOCNAME[9]; // string parm is passed into this header
} DSD550413M, *LPDSD550413M; // and stored in this struct
#define IDERRszDOCNAME_2 1L
#endif
......
// code from .c
#define B550413M_c
#include <B550413M.h> // this is header above
{
int nResult = 0;
PFNJDE2CM lpJDE2CM;
HINSTANCE hLibrary;
hLibrary = LoadLibrary("c:\\JDE2CM.dl
if(hLibrary != NULL)
{
// gets the address of the function inside the VB dll
lpJDE2CM = (PFNJDE2CM) GetProcAddress (hLibrary, "DllGetClassObject");
if(!lpJDE2CM)
FreeLibrary(hLibrary);
else
{
// call the VB dll function
const char *docid = 0;
docid = lpDS->szDOCNAME;
nResult = lpJDE2CM(docid);
}
}
return (ER_SUCCESS);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i've never done this, but i would suggest maybe disassembling a vb written exe that makes use of the same dll. the reason being i bet there is a bootstrap of sorts that centers around the msvbxxx.dll runtime, and _perhaps_ even plays a role in providing a layer of com dispatching. i'm not certain of either of those things, but they sound logical at the surface level.
Try these:
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=3550050c.7231999%40news.ko.kcp.com&rnum=1&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=OfD%242lL6%23GA.252%40cppssbbsa03&rnum=3&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=OLrcy9Y6%23GA.259%40cppssbbsa03&rnum=4&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=O9BHb1gMAHA.195%40cppssbbsa04&rnum=8&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=74aier%24m6l%241%40nnrp1.dejanews.com&rnum=10&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=3550050c.7231999%40news.ko.kcp.com&rnum=1&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=OfD%242lL6%23GA.252%40cppssbbsa03&rnum=3&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=OLrcy9Y6%23GA.259%40cppssbbsa03&rnum=4&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=O9BHb1gMAHA.195%40cppssbbsa04&rnum=8&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=74aier%24m6l%241%40nnrp1.dejanews.com&rnum=10&prev=/groups%3Fq%3DCall%2BVB%2BActiveX%2Bdll%2Bfrom%2BC%2Blanguage%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch
Just do a google on 'call vb activex dll c language' in google groups.
U'll get plenty of similar links.
U'll get plenty of similar links.
ASKER
I'm still alive but dying to get rid of the 250 points...
I've written 2 cpp wrappers using some of the info from the links - thanks for the tip.
One of them disassembles the VB code and one imports the VB code. One is an exe and one is a dll.
They both only compile if an unsigned short** datatype is passed to the VB function, but the function actually receives a string (coded in the VB function). Why is this?
The only other problem I have is I get a link error:
LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
When I try to go into the MS Studio Project Settings, the Link tab is missing??? I think this may be because of the J.D.Edwards not accepting any of the cpp code or settings. Id their a manual way to run the link from DOS?
I've written 2 cpp wrappers using some of the info from the links - thanks for the tip.
One of them disassembles the VB code and one imports the VB code. One is an exe and one is a dll.
They both only compile if an unsigned short** datatype is passed to the VB function, but the function actually receives a string (coded in the VB function). Why is this?
The only other problem I have is I get a link error:
LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
When I try to go into the MS Studio Project Settings, the Link tab is missing??? I think this may be because of the J.D.Edwards not accepting any of the cpp code or settings. Id their a manual way to run the link from DOS?
See this:
http://www-unix.mcs.anl.gov/mpi/mpich/docs/mpichntman/node10.htm
It shows how to compile in VC++ from the command line.
It should solve ur problem.
U can explicitly call the link.exe and give the /NODEFAULTLIB option there.
http://www-unix.mcs.anl.gov/mpi/mpich/docs/mpichntman/node10.htm
It shows how to compile in VC++ from the command line.
It should solve ur problem.
U can explicitly call the link.exe and give the /NODEFAULTLIB option there.