I am having problems with a function in a DLL that is being called by a customer supplied OCX. I have included the relevant source code below:
char* __stdcall test_to_perform(int communications_port, VARIANT serial_number, VARIANT model_type)
{
unsigned long id;
char model[25];
char *pointer;
int com_port;
com_port = communications_port;
CA_VariantConvertToType(&serial_number, CAVT_CSTRING, &pointer);
Scan(pointer, "%s>%i", &id);
CA_VariantConvertToType(&model_type, CAVT_CSTRING, &pointer);
strcpy(model, pointer);
...
If the following values are passed to the function by the OCX:
communications_port: 1
serial_number: "123456789A"
model_type: "ABCDEFGHIJ"
The value of the local variables are:
com_port: 1
model: 65 (ASCII value for 'A')
id: 49 (ASCII value for '1')
When I look at the variable views for 'serial_number' and 'model_type', the following is shown:
serial_number: {VT_UI1 | VT_BYREF, 49}
model_type: {VT_UI1 | VT_BYREF, 49}
What can I do to get the correct values for the VARIANT variables that are passed from the OCX?
Thanks in advance,
Mitch