DLL problem - C to VB6

P

Peter

i wrote the following snippet in C

__declspec(dllexport) __stdcall int print2scrn(char *name)

I declared in VB6...

declare function wipefiles lib "ctools" print2scrn(strng as string) as
integer
or
declare function wipefiles lib "ctools" print2scrn(strptr(strng as
string)) as integer

(I don't need to declare Alias... or @ since i didn't compile with
underscores)

all my call come back with...
"Can't find DLL entry point print2scrn in ctools"
i've written quite a few other c functions and called them from VB, but
this is a first for me with a STRING. Anybody know anything about how to
do this?
thx, Peter
 
H

Herfried K. Wagner [MVP]

Peter said:
i wrote the following snippet in C

__declspec(dllexport) __stdcall int print2scrn(char *name)

I declared in VB6...

This is a VB.NET language group. You will more likely get an answer if you
post the question to one of the VB Classic groups (microsoft.public.vb.*).
 
F

Fergus Cooney

Hi Peter,

The interface between VB.NET and C is different to that of VB classic and
C. A whole different set of "can't do"s and "can't find"s for you to solve!!

Although I don't know your answer, a bit of info that might help. Strings
in C consist of a pointer to a buffer. The string is zero-terminated. Lovely
and simple. Strings in VB have a header which includes the length. When you
are passing a string from Basic to C you need to take this into account. Sorry
I can't give you any more than that.

Regards,
Fergus
 
?

=?iso-8859-1?Q?Jos=E9_Manuel_Ag=FCero?=

Hello, Peter:

"Can't find DLL entry point print2scrn in ctools" means you haven't exported the function in your dll or VB can't find the library.
The VB declaration should be:
declare function wipefiles lib "ctools.dll" print2scrn(byval strng as string) as integer 'VB6
declare Ansi function wipefiles lib "ctools.dll" print2scrn(byval strng as string) as short 'VB .NET

The runtime will convert the string to a zero terminated one in both languages. In .NET it also converts the string to Ansi (you may have to use "Unicode" instead of "Ansi" depending on your dll).
Remember that although the string is passed ByVal, your dll can change it and the runtime will convert it back to the VB program: that is, the VB program will see the string modified.

Regards.


"Peter" <[email protected]> escribió en el mensaje | Sorry, didn't know it was VB.Net!
| does the same not apply to VB.Net?
| Peter
|
| Herfried K. Wagner [MVP] wrote:
| >
| >>i wrote the following snippet in C
| >>
| >>__declspec(dllexport) __stdcall int print2scrn(char *name)
| >>
| >>I declared in VB6...
| >
| >
| > This is a VB.NET language group. You will more likely get an answer if you
| > post the question to one of the VB Classic groups (microsoft.public.vb.*).
| >
|
 
F

Fergus Cooney

Hi Peter,

|| function wipefiles ... print2scrn (strng as string

I meant to ask - what's the connection between wiping files and printing
to the screen?

Regards,
Fergus
 

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