Article View: att.lang.c++
Article #151Need superior Guru help with C DLL for VB
From: Mark E.
Date: Sun, 24 Jan 1999 00:00
Date: Sun, 24 Jan 1999 00:00
62 lines
2681 bytes
2681 bytes
I Need superior Guru help with C DLL for VB
I have a C DLL that is being developed, however in VB I get the following
error with the following C interfaces to the DLL: (My VB Code is at the
bottom of this message)
What can be done so these errors don't occur in the VB IDE (or compiled as
pseudocode)?
I am using VB 5 and have no problems declaring or utilizing DLL's in
general.
I know my problem is probably with the C code. What can be done to fix it?
With the following code I get the following error when attempting to run the
corresponding VB code in the VB IDE (or compiled as p-code): "Run-Time error
49: Bad DLL Calling convention". NOTE: If I compile the VB Code down below
to n native code exe it appears to work correctly. (However, because this is
not good enough for me, since it won't work in the IDE, then something may
be declared incorrectly and memory errors might occur later on)
SOX1 (withOUT stdcall):
_declspec(dllexport) void __stdcall SOX(LPCSTR, LPCSTR, LPCSTR, LPCSTR,
LPCSTR);
LPCSTR cmd,
LPCSTR stdout_fl,
LPCSTR out,
LPCSTR stderr_fl,
LPCSTR err)
void SOX(
{...}
The following code produces the following error when executed in the VB IDE
(when run as p-code) or as a native code executable: "Run-Time Error 453:
Can't find entry point in sox2.dll"
SOX2 (WITH stdcall):
_declspec(dllexport) void SOX(LPCSTR, LPCSTR, LPCSTR, LPCSTR, LPCSTR);
void __stdcall SOX(
LPCSTR cmd,
LPCSTR stdout_fl,
LPCSTR out,
LPCSTR stderr_fl,
LPCSTR err)
{...}
Here is my VB Declaration:
'Test DLL1
Private Declare Sub SOX Lib "sox1.dll" (ByVal Cmd As String, ByVal
OutMessFile As String, ByVal OutMess As String, 'Test DLL2
'Private Declare Sub SOX Lib "sox2.dll" (ByVal Cmd As String, ByVal
OutMessFile As String, ByVal OutMess As String,
ByVal ErrMessFile As String, ByVal ErrMess As String)
Here is the VB Function that calls the DLL:
Function TestCode()
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim e As String
a = txtIn.Text
b = "out.tmp"
c = String(513, " ") 'Create a buffer of 513
d = "err.tmp"
e = String(513, " ") 'Create a buffer of 513
SOX a, b, c, d, e
txtOut.Text = c
txtErr.Text = e
End Function
Technical Details
Message-ID:
<78fmv9$f40$1@news.megsinet.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4ba,57ebf99890f5de83,start X-Google-Attributes: gid10d4ba,public From: "Mark E." <mje@cyberbiz.com> Subject: Need superior Guru help with C DLL for VB Date: 1999/01/24 Message-ID: <78fmv9$f40$1@news.megsinet.net> X-Deja-AN: 436400505 Organization: MegsInet, Inc. - Low Cost, High Performance Internet Services X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Newsgroups: att.lang.c++