prophet001
asked on
Pointers in VBScript
Hi,
I am trying to use a COM object in VBScript to do some cool things to our SFTP server and need a little bit of help. The server offers an API callable through a COM interface and I am trying to use this in VBScript.
Specifically, I am trying to make a call to a function that uses a pointer to a BSTR for an [out] value that it will return.
I create the object without any problems and try to call the function but VBScript stops me. (I think it's VBScript, it might be making it to the COM server idk.)
Here is the prototype for the function:
SVR_GetAttr(LPCTSTR szServerName, LPCTSTR szAttrName, BSTR* pszAttrValue);
and this is how I've tried to call it
Dim attr
obj = 'create object here
obj.SVR_GetAttr "servername", "attrname", attr
^--- fails
Thank you for any help that you can give on this. I'm not even sure if VBScript supports this type or not.If I have to I guess I could go into C# or C++ but I would rather not.
Thank you again,
Preston
I am trying to use a COM object in VBScript to do some cool things to our SFTP server and need a little bit of help. The server offers an API callable through a COM interface and I am trying to use this in VBScript.
Specifically, I am trying to make a call to a function that uses a pointer to a BSTR for an [out] value that it will return.
I create the object without any problems and try to call the function but VBScript stops me. (I think it's VBScript, it might be making it to the COM server idk.)
Here is the prototype for the function:
SVR_GetAttr(LPCTSTR szServerName, LPCTSTR szAttrName, BSTR* pszAttrValue);
and this is how I've tried to call it
Dim attr
obj = 'create object here
obj.SVR_GetAttr "servername", "attrname", attr
^--- fails
Thank you for any help that you can give on this. I'm not even sure if VBScript supports this type or not.If I have to I guess I could go into C# or C++ but I would rather not.
Thank you again,
Preston
ASKER
yeah i shouldn't have typed that. I just was trying to not expose the COM object. The COM object is created properly without issue.
Sorry,
Preston
Sorry,
Preston
Can you try this?
obj.SVR_GetAttr "servername", "attrname", CStr(attr)
sew
obj.SVR_GetAttr "servername", "attrname", CStr(attr)
sew
ASKER
well it's not breaking but it's not returning values to the variables either. I used CStr(attr) and the program ran without issue but when i view the contents of the variable it doesn't have anything in it.
There is another function whose prototype is:
SVR_GetAttr2(LPCTSTR szServerName, LPCTSTR szAttrName, BSTR* pszAttrValue, LONG* lError);
and i used this with CLng(errRes) for the last parameter and there was no value in the errRes variable. It seems like the variables aren't being passed as pointers and aren't receiving input from the COM server.
There is another function whose prototype is:
SVR_GetAttr2(LPCTSTR szServerName, LPCTSTR szAttrName, BSTR* pszAttrValue, LONG* lError);
and i used this with CLng(errRes) for the last parameter and there was no value in the errRes variable. It seems like the variables aren't being passed as pointers and aren't receiving input from the COM server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
:(
so pretty much it won't work. I don't have access to the source code and can't rewrite it or do any fixing of it.
thank you for finding this sungenwang. I appreciate your help.
:)
Preston
so pretty much it won't work. I don't have access to the source code and can't rewrite it or do any fixing of it.
thank you for finding this sungenwang. I appreciate your help.
:)
Preston
You're welcome!
obj = 'create object here
change is to something like:
Set obj = CreateObject("your_object_
sew