HI all, this is my first post here.
I have to call an ActiveX dll (made in VB), When I explore the dll this is what I get
----------------------------------------------------------------------
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: RETRIEVE.dll
[
uuid(CC3FB919-B773-11D7-9E25-0001021851E5),
version(2.0)
]
library RETRIEVE
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("Stdole2.tlb");
// Forward declare all types defined in this typelib
interface _clsRetrieve;
[
odl,
uuid(CC3FB925-B773-11D7-9E25-0001021851E5),
version(1.0),
hidden,
dual,
nonextensible,
oleautomation
]
interface _clsRetrieve : IDispatch {
[id(0x60030000)]
HRESULT GetDocFromArchive(
[in, out] BSTR* DA_DocGroupID,
[in, out] BSTR* Ext_DocID,
[in, out] BSTR* DADocArchivingDate,
[in, out] BSTR* DADocArchivingTime,
[in, out] BSTR* DAFileIDs,
[in, out, optional] BSTR* DADocModifyDate,
[in, out, optional] BSTR* DADocModifyTime,
[out, retval] BSTR* );
};
[
uuid(CC3FB926-B773-11D7-9E25-0001021851E5),
version(1.0)
]
coclass clsRetrieve {
[default] interface _clsRetrieve;
};
};
--------------------------------------------------------------------
and I am trying to use that procedure from C++
This is the part of the code. Please read the comments..
// here might be the my problem, is this typedef right?
// I know that the 2 fist vars are byval.
typedef BSTR ( CALLBACK* myGetDocFromArchive) (
BSTR DA_DocGroupID,
BSTR Ext_DocID,
BSTR* DADocArchivingDate,
BSTR* DADocArchivingTime,
BSTR* DAFileIDs,
BSTR* DADocModifyDate,
BSTR* DADocModifyTime );
myGetDocFromArchive GetDocFromArchive;
// Load the DLL into memory.
HINSTANCE hLib = LoadLibrary("RETRIEVE.dll");
// Make sure to check if it was loaded successfully.
if(hLib == NULL)
{
cout << "ERROR: Unable to load library!" << endl;
getch();
return -1;
}
// Finds the path of the client application.
char mod[100];
GetModuleFileName((HMODULE)hLib,(LPTSTR)mod,100);
cout << "Library Loaded: " << mod << endl;
//UNTILL NOW THE LIBRARY LOADED WELL
// Finds the addresses of all the DLL's functions.
// HERE IS THE PROBLEM GetDocFromArchive is NULL WHY?
GetDocFromArchive = (myGetDocFromArchive)GetProcAddress((HMODULE)hLib, "clsRetrieve.GetDocFromArchive");
.
.
.
.
// Free the DLL from memory.
FreeLibrary((HMODULE)hLib);
-----------------------------------------------------------------
The problem is that it never finds the Procedure Address so GetDocFromArchive always is 0x0000000 (NULL).
The question is What is wrong here, is it is my typedef?
I have registered the dll.
Thank you.
froque