Creating DLL for usage using vbs

A

alexia.bee

Hi all,

I need to develop dll which should be used by vbs. the dll should
return 2D arrays, strings and other var types.
I am not sure which with which language I should do it. I debate
between C++ and C#.

The problem is that the DLL uses pointers (WLAN APIS). Does C++ dll
can return to vbs these kind of variables?
Is it not right to create this kind of dll in C#?

thanks for the help.
Alexia.
 
N

Nicholas Paldino [.NET/C# MVP]

Alexia,

You can create this type of COM component in either C++ or C#. I
personally think that it is better in C#, but you have to decide what you
are most comfortable with.

What you are going to have to figure out though is how to represent this
information to VB Script. The pointers that you are passing around can't be
dereferenced in VB script, so you will have to create some sort of object
model and pass that around, converting when necessary, if you wish to make
any adjustments in the VB Script.
 
W

Willy Denoyette [MVP]

Hi all,

I need to develop dll which should be used by vbs. the dll should
return 2D arrays, strings and other var types.
I am not sure which with which language I should do it. I debate
between C++ and C#.

The problem is that the DLL uses pointers (WLAN APIS). Does C++ dll
can return to vbs these kind of variables?
Is it not right to create this kind of dll in C#?

thanks for the help.
Alexia.



Not sure why you need to pass pointers, VBS doesn't know about pointers,
mind to explain what you are after?

Willy.
 
A

alexia.bee

Hi Willy and Nicholas thanks for the reply,

I didn't explain my self well. I don't need to return pointers to vbs.
The dll I am talking about is using pointers to and receive data from
other APIs. I wasn't sure if C# dll is the right language for that.

I can cast the pointers structures to arrays and return that to vbs.


Thanks.
Alexia.
 
N

Nicholas Paldino [.NET/C# MVP]

Alexia,

No, you can't do a direct cast (without unsafe code), but you can
marshal the structures from unmanaged memory (where the pointer value to
that unmanaged memory is going to be stored in an IntPtr) to managed memory,
and then return those classes to VBScript.

You would be better off passing classes which are Automation compatable
back to VB Script.
 
A

alexia.bee

Alexia,

    No, you can't do a direct cast (without unsafe code), but you can
marshal the structures from unmanaged memory (where the pointer value to
that unmanaged memory is going to be stored in an IntPtr) to managed memory,
and then return those classes to VBScript.

    You would be better off passing classes which are Automation compatable
back to VB Script.

--
          - Nicholas Paldino [.NET/C# MVP]
          - (e-mail address removed)




Hi Willy and Nicholas thanks for the reply,
I didn't explain my self well. I don't need to return pointers to vbs.
The dll I am talking about is using pointers to and receive data from
other APIs. I wasn't sure if C# dll is the right language for that.
I can cast the pointers structures to arrays and return that to vbs.
Thanks.
Alexia.- Hide quoted text -

- Show quoted text -

Nicholas, thanks for the input for returning class to vbs.

So you still think that it is better using C# over C++ dll for
unmanaged?

When returning class from dll to vbs, I should define class in vbs
with the exact number of parameters the dll returns?
how about casting the class members to vbs?

thanks.
 
W

Willy Denoyette [MVP]

Alexia,

No, you can't do a direct cast (without unsafe code), but you can
marshal the structures from unmanaged memory (where the pointer value to
that unmanaged memory is going to be stored in an IntPtr) to managed
memory,
and then return those classes to VBScript.

You would be better off passing classes which are Automation compatable
back to VB Script.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Hi Willy and Nicholas thanks for the reply,
I didn't explain my self well. I don't need to return pointers to vbs.
The dll I am talking about is using pointers to and receive data from
other APIs. I wasn't sure if C# dll is the right language for that.
I can cast the pointers structures to arrays and return that to vbs.
Thanks.
Alexia.- Hide quoted text -

- Show quoted text -

Nicholas, thanks for the input for returning class to vbs.

So you still think that it is better using C# over C++ dll for
unmanaged?

When returning class from dll to vbs, I should define class in vbs
with the exact number of parameters the dll returns?
how about casting the class members to vbs?

thanks.



This is not a matter of C# or C++, the real problem is VBScript. You need to
make sure you are returning your data as automation types, whether you use
C# as COM server or C++ doesn't matter here.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top