DLL problem - C to VB6

  • Thread starter Thread starter Peter
  • Start date Start date
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
 
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.*).
 
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
 
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.*).
| >
|
 
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
 
Back
Top