WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.


!! WIL SDK !!

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Answerstring Description

Keywords: 	 Answerstring WIL SDK


I cannot find any examples, or documentation that explains this "ANSWERSTRING" macro in the extender. It claims to have a global buffer somwhere, and returns a large string to the WIL but doesnt return control back to the script. How is this ANSWERSTRING intended to be used? The comments in the wilx.c do NOT clarify anything.



Basically if you do a GLOBALALLOC in your code for some function and put your answer into the memory buffer that was allocated, then you must do two things.
  1. Return your answer to WinBatch via the ANSWERSTING macro.

  2. Then GlobalFree your buffer after the ANSWERSTRING macro returns.
If you used the RETSTRING macro instead, the answer would get back to WinBatch, but your code would be over and there would be a lost GlobalAlloc'ed buffer, creating a memory leak unless you carefully planned for this to occur.

Question (cont'd):

Can you give an example of the script and a short extender case stub that would do what you say. I am confused on how the SCRIPT will be able to access such a buffer.

Also, can I assume this would work for ANY heap space? Is there any reason malloc cannot be used instead of the GlobalAlloc(non-win32)???


The ASNWERSTRING macro will cause the contents of the buffer to be copied to a WinBatch variable. Then the data in the buffer is redundant and can be eliminated.

Note: In general the GlobalAlloc function is preferred in WinBatch to the malloc function when passing data from an extender to the main DLL.


  case 15:  
          LPSTR lpH;
                  LONG retvalue;
                  lstrcpy(lpH,"Hello World");
                  return retvalue;

Article ID:   W14198
Filename:   Answerstring Description.txt
File Created: 2017:07:28:13:58:14
Last Updated: 2003:07:24:10:21:47