C#: Parse String to BSTR Type

Using method in COM interface, requires BSTR (wtf?)

Page 1 of 1

4 Replies - 9977 Views - Last Post: 11 June 2007 - 08:51 AM Rate Topic: -----

#1 killnine  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 161
  • Joined: 12-February 07

C#: Parse String to BSTR Type

Post icon  Posted 07 June 2007 - 07:43 AM

Howdy folks,
Good to be here, been lurking for a while and enjoyed community here.

Now it is I that has a question.

I am working on a GUI for an api that my employer uses for its controllers. Anyhow, one of the methods I need to utilize has the arguments:

long TcpIPConnect(BSTR [i]TargetIpAddress[/i], BSTR [i]TargetPort[/i]);



Straightforward, huh? Well, I am using textboxes to gather the required address and port from the user. However, I cannot just cast this object to the BSTR (Binary string?) type.

Can anyone help me? Thanks!

Is This A Good Question/Topic? 1

Replies To: C#: Parse String to BSTR Type

#2 killnine  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 161
  • Joined: 12-February 07

Re: C#: Parse String to BSTR Type

Posted 07 June 2007 - 08:05 AM

View Postkillnine, on 7 Jun, 2007 - 07:43 AM, said:

Howdy folks,
Good to be here, been lurking for a while and enjoyed community here.

Now it is I that has a question.

I am working on a GUI for an api that my employer uses for its controllers. Anyhow, one of the methods I need to utilize has the arguments:

long TcpIPConnect(BSTR [i]TargetIpAddress[/i], BSTR [i]TargetPort[/i]);



Straightforward, huh? Well, I am using textboxes to gather the required address and port from the user. However, I cannot just cast this object to the BSTR (Binary string?) type.

Can anyone help me? Thanks!



I actually think I solved my own problem. I tried just using an integer and it worked fine. I have no idea why my reference documentation says it requires a BSTR. Strange.....
Was This Post Helpful? 0
  • +
  • -

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1877
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: C#: Parse String to BSTR Type

Posted 07 June 2007 - 08:06 AM

Nice. Glad you got it fixed, and welcome to dream.in.code... hope to see you around in the forums a little more. We like lurkers, but regulars are even better :)
Was This Post Helpful? 0
  • +
  • -

#4 SMcLellan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-June 07

Re: C#: Parse String to BSTR Type

Posted 10 June 2007 - 12:54 AM

Sounds like you're doing some kind of interop scenario...

Check out http://pinvoke.net/ for method signatures related to calling Win32 and other unmanaged apis.
Was This Post Helpful? 0
  • +
  • -

#5 killnine  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 161
  • Joined: 12-February 07

Re: C#: Parse String to BSTR Type

Posted 11 June 2007 - 08:51 AM

View PostSMcLellan, on 10 Jun, 2007 - 12:54 AM, said:

Sounds like you're doing some kind of interop scenario...

Check out http://pinvoke.net/ for method signatures related to calling Win32 and other unmanaged apis.



Yeah, I am doing an application for Mathwork's xPC. Its for testing Simulink-generated C code for controls applications.


Anyhow, I am using a DLL provided by Mathworks and its documentation is a little sketchy. Im no pro but I have already found 2-3 errors in their documentation. Not fun when you just drop 50k on their products. =P
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1