From: Leo on
I have some code I am thinking of sticking in a standard dll which
needs to have strings passed to it. What is the best way to do this
with me seeing the chance that non VB code could be calling this code.
Should I use pointers and convert to a VB string?

--
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


From: Mayayana on
You can use strings OK, but you don't get
the usual (hidden) conversion to and from
ANSI/Unicode. If you want to send and retrieve
strings as you would in VB, use StrConv(s, vbUnicode)
on the incoming strings and StrConv(s, vbFromUnicode)
when returning a string value.

I've got a basic sample with info. here:

www.jsware.net/jsware/vbcode.php5#vdll

I developed it with a lot of help from an article here:

http://windowsdevcenter.com/pub/a/windows/2005/04/26/create_dll.html


|I have some code I am thinking of sticking in a standard dll which
| needs to have strings passed to it. What is the best way to do this
| with me seeing the chance that non VB code could be calling this code.
| Should I use pointers and convert to a VB string?
|
| --
| ClassicVB Users Regroup! comp.lang.basic.visual.misc
| Free usenet access at http://www.eternal-september.org
|
|


From: Kevin Provance on

"Leo" <ttdhead(a)gmail.com> wrote in message
news:i1sjhk$udb$1(a)news.eternal-september.org...
:I have some code I am thinking of sticking in a standard dll which
: needs to have strings passed to it. What is the best way to do this
: with me seeing the chance that non VB code could be calling this code.
: Should I use pointers and convert to a VB string?

What language are you using to write the standard DLL? If it's your
intention to use the DLL with VB, what's wrong with a COM DLL? I used them
all the time without any problems, expecially where reusable code is
concerned.

If you plan to use VB to author the DLL with the various hacks available,
there are caveats. If you're using the DLL with your VB project, then you
don't need to worry about intiailizing the VB runtime (something you would
have to do if the DLL was to be used with a language other than VB). As far
as passing strings using this method, there are gotchas and hiccups along
the way. The one time I experimented with it (but don't do it with
production code) I took the route the SHLWAPI API uses and pass the strings
as long pointers. Yes, there is an extra step involved, but it's faster and
more reliable (which is up for debate, I suppose).

Take a look here to see what I am talking about:
http://msdn.microsoft.com/en-us/library/aa155716%28office.10%29.aspx. It
talks about using string pointers instead of strings...plus reveals some
cool APIs you may or may not have known about. :-)

- Kev

From: Jim Mack on
Leo wrote:
> I have some code I am thinking of sticking in a standard dll which
> needs to have strings passed to it. What is the best way to do this
> with me seeing the chance that non VB code could be calling this
> code. Should I use pointers and convert to a VB string?

What language would you use to write this DLL?

--
Jim Mack
Twisted tees at http://www.cafepress.com/2050inc
"We sew confusion"
From: Leo on
Jim Mack wrote :
> Leo wrote:
>> I have some code I am thinking of sticking in a standard dll which
>> needs to have strings passed to it. What is the best way to do this
>> with me seeing the chance that non VB code could be calling this
>> code. Should I use pointers and convert to a VB string?
>
> What language would you use to write this DLL?

VB

--
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


 |  Next  |  Last
Pages: 1 2 3 4 5
Prev: New form on Main thread.
Next: Pasting text to browser