I am trying to create a VC++ ATL COM DLL that will be eventually used in a web page.
The DLL will essentially be a wrapper object for some API calls. Since I'm new at C++, to start simple I created the DLL with a single function which calls GetUserName(). After finally getting the DLL to build I tested the component in VFP and VB but received various kinds of errors:
In VB when trying to build the EXE:
"Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic"
I do not think the the function is restricted so I believe the problem is in the parameter(s) data typing.
In VFP the object would instantiate but when calling the function I get either a "OLE error code ... bad variable type" or "Data type mismatch" depending on how I declared the C++ function parameters.
In trying to track down my problem I eliminated the call to GetUserName() and just set a return value to test the function parameters and create the function with one parameter at a time to test the parameter calling integrity. I was originally declaring one of the parameters as a LPDWORD, but this seemed to cause one of the errors on the calling side so I changed it to a pointer to long ( long* ) and this seemed to fix this parameter.
The other parameter is a string type parameter so I declared it LPTSTR along the declaration form for GetUserName(). This too caused the errors. I have been unable to find the correct declaration for this string type parameter for the COM interface.
Therefore, I need some general guidance in declaring the parameter data types to be used in the COM DLL function parameters for the COM interface. The MSDN library descriptions of API functions seem to indicate to use LPTSTR, LPDWORD, etc. but these do not seem to work. Is there documentation indicating the parameter declaration types for COM interfaces? I have not been able to locate anything like this.
Of course, with my newness to this platform, I realize I may not be providing adequate details for analysis of the problem. I will gladly give more specific details if I know what to provide or post actual code.
I am basically following Ivor Horton's first example in his
Beginning VC++6, "Using the Active Template Library" chapter. This example is pretty straightforward but only passes data types of long or pointer to long.
Thanks,
Bill
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.