?
Solved

Pointers in VBScript

Posted on 2011-04-27
7
Medium Priority
?
1,545 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:prophet001
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:sungenwang
ID: 35479013
This line probably caused the problem:

   obj = 'create object here

change is to something like:

   Set obj = CreateObject("your_object_name")


sew
0
 

Author Comment

by:prophet001
ID: 35479053
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
0
 
LVL 14

Expert Comment

by:sungenwang
ID: 35479215
Can you try this?

obj.SVR_GetAttr "servername", "attrname", CStr(attr)

sew
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:prophet001
ID: 35479610
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.
0
 
LVL 14

Accepted Solution

by:
sungenwang earned 2000 total points
ID: 35479620
Searched around and found this:
http://blogs.msdn.com/b/ericlippert/archive/2003/09/29/53117.aspx?Pending=true

Looks like vbscript has issues with pointers...
0
 

Author Comment

by:prophet001
ID: 35483114
:(

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
0
 
LVL 14

Expert Comment

by:sungenwang
ID: 35483307
You're welcome!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question