Showing results for 
Search instead for 
Did you mean: 

ActiveX server output strings

I'm working on creating an ActiveX server executable with a number of interfaces. Each interface includes at least a couple methods that need to provide string output. The canonical prototype for such a method would simply accept a pointer to char for the output parameter:


HRESULT method1(char *outputString);


The ActiveX server editor dialog for method entries provides options for both input and output strings. If I specify outputString as an "output string", the prototype that's generated is:


HRESULT method1(char **outputString);


If I specify that it is an "input string", I get the desired prototype in the generated server code, but the corresponding controller code method specifies this parameter as "const char *", meaning that it can only be read, not written; so this isn't workable.


If I specify that is an "output char", I also get the desired prototype, but in this situation, the generated code only copies 1 character into the output string; so this isn't workable either.


So I've tried using the prototype produced for "output string" (see above). My server implementation for this method refers to *outputString, e.g.,


strcpy(*outputString, "Hello");


to populate the output parameter. On the client side, I pass in the address of a pointer-to-char that points to a string, e.g., &op where:


char output[1024];

char *op = output;


Each time I invoke this corresponding client-side operation, the server crashes; *outputString in the strcpy function call evaluates to NULL. I'm sure I must have something wrong with my approach here. Is there a preferred approach for handling output strings in an ActiveX server?


Many thanks in advance!




0 Kudos
Message 1 of 3

I don't know if this is helpful at all, but there is an example that uses output strings, SimpleEXE.cws. It may be beneficial to see how it is handled there. The method in question is the Add method in the IString interface. 

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 2 of 3

Thanks, Steven. I had sort-of independently discovered that the use of CA_AllocMemory and CA_FreeMemory were needed to make output strings (and other output arrays) work. I've successfully tested a simple example that gives the correct result.




0 Kudos
Message 3 of 3