Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 DLL calling...

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
VBBR Posted - Jul 10 2004 : 08:35:16 AM
If I'm calling an external function from a DLL, where one of its arguments in C is defined as "const char *variable", how should I pass the string? ByVal or ByRef? Should I append a Chr(0) at the end of the string?
3   L A T E S T    R E P L I E S    (Newest First)
Eric Coleman Posted - Jul 11 2004 : 01:49:01 AM
You can also decalre the function as ByRef Data As Any instead of ByVal Data As Long.

To call the function when decalared as ByRef Data As Any, you use the following syntax for Single and Double byte systems.

For single byte characters
Dim S as string: s = "hello"
Dim bytArray() as Byte
bytArray = StrConv(S & Chr$(0), vbFromUnicode)
Call MyFunction ( bytArray(0) )

For Double byte characters.
Dim S as string: s = "hello"
Dim bytArray() as Byte
bytArray = S & Chr$(0)
Call MyFunction ( bytArray(0) )
Eric Coleman Posted - Jul 11 2004 : 01:36:49 AM
Is it a double byte character function or a single byte?

For a single byte function, you would declare it as

(ByVal Data As Long)

and then to call the funtion..

Dim S as String: S = "hello"
Call MyFunction(StrPtr(StrConv(S, vbFromUnicode)))


For a double byte string, you would decalre the function the same way.

(ByVal Data As Long)

but when calling the function it would look like

Dim S as String: S = "hello"
Call MyFunction(StrPtr(S))
Sr. Guapo Posted - Jul 10 2004 : 11:15:46 AM
I'm not sure if you can pass a constant, seems like that wouldn't work... Also, I don't *think* you can pass an actual "pointer" from VB, but you can pass a reference. They are similar, and I don't know what's different. If you can't tell, my C++ skills are severly lacking, sorry I couldn't be of more help.

VBGamer © Go To Top Of Page
This page was generated in 0.06 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.