You'll have to use Active Accessibility to obtain, not a handle, but an
interface to the caption. You can get an IAccessible interface from an HWND, and from that, obtain the IAccessible for the caption. Accessibility Explorer will help you here (it's an MS development tool).
Once you have the caption's IAccessible, I believe the method is called acc_SetText(). As it's a COM interface, it'll require you to pass a BSTR. A hack is to pass a wchar_t pointer, but be warned: as a wchar_t* isn't a fully-defined BSTR, the code may not be perfectly stable.
Of course, if this is going to be entirely in JScript, all strings are BSTR by default