This would be a step towards a sync javascript runtime which can interact with VBA.
Chakracore.dll can't support JsValueToVariant ,so change to this:
'Run = helperJS2VB(R)
Run = JsValueToSTR(R)
Private Declare Function JsConvertValueToString Lib "Chakra.dll" (ByVal m_JsValue As Long, ByVal VARPTR_RESULstr As Long) As Long
Private Declare Function JsStringToPointer Lib "Chakra.dll" (ByVal m_JsValue As Long, stringValue As Long, stringLength As Long) As Long
Public Declare Function SysReAllocString Lib "oleaut32.dll" (ByVal pBSTR As Long, Optional ByVal pszStrPtr As Long) As Long
Public Function GetStrFromPtrw(ByVal Ptr As Long) As String
'GOOD(ptr前面是4个字节的长度)
SysReAllocString VarPtr(GetStrFromPtrw), Ptr
End Function
Function JsValueToSTR(m_JsValue As Long) As String
Dim JsStringPtr As Long
Dim VbStringPtr As Long
Dim StringLen As Long
Dim ret As Long
ret = JsConvertValueToString(m_JsValue, VarPtr(JsStringPtr))
ret = JsStringToPointer(JsStringPtr, VbStringPtr, StringLen)
JsValueToSTR = GetStrFromPtrw(VbStringPtr)
End Function
```vb
Honestly this whole class needs a total rewrite. It was made when I was younger and more naive.
Chakracore.dll
can't supportJsValueToVariant
,so change to this: