I need help from a vb and vc++ expert 
Author Message
 I need help from a vb and vc++ expert

Jonathan,
If the parametars are passed correctly, I would guess GFP is caused by
the function itself.  Here is a small basic sample.

From VC++:

extern "C" BOOL Pascal EXPORT ExportedFunction(int i,char* szTest)
{
        char szChr[10];

        itoa(i,szChr,10);
        AfxMessageBox(szChr);

        AfxMessageBox(szTest);

        return TRUE;

Quote:
}

In DEF file:
EXPORTS
    ; Explicit exports can go here

Calling From VB:
Declare Function ExportedFunction Lib "yourdll" (ByVal i As Integer,
ByVal szChar As String) As Boolean

Private Sub Command5_Click()
    Dim bRetval As Boolean

    bRetval = ExportedFunction(100, "Made it - Have Fun")
End Sub

Run your VC++ app in debug mode with breakpoints and check out passing
parameters from your VB app.  I do it all the time.

HTH



Quote:
> I am having trouble getting vb to call my vc++ dll. Everytime I run my
> demo,
> I get a GPF. The Visual C++ demo program I wrote works fine. If there
is
> anyone
> out there who is an expert on matters concerning the use of and
writing
> of vc++
> dlls for vb then e-mail me and I will send you the visual c++ dll and
> source
> and the vb demo program and source. BTW I am using visual studio 6 to
do
> all this.

> --
> Jonathan Wilson

> http://www.*-*-*.com/

Sent via Deja.com http://www.*-*-*.com/
Before you buy.


Sat, 06 Jul 2002 03:00:00 GMT  
 I need help from a vb and vc++ expert
Jonathan,
 When you are calling the VC++ DLL's from your program , check the
declaration , the data types and ByRef / ByVal properties. You may need to
change the data-types from VC DLL to VB , probably that's what is causing
the problem.

Regards,
Adheer.


Quote:
> I am having trouble getting vb to call my vc++ dll. Everytime I run my
> demo,
> I get a GPF. The visual c++ demo program I wrote works fine. If there is
> anyone
> out there who is an expert on matters concerning the use of and writing
> of vc++
> dlls for vb then e-mail me and I will send you the visual c++ dll and
> source
> and the vb demo program and source. BTW I am using visual studio 6 to do
> all this.

> --
> Jonathan Wilson

> http://members.xoom.com/wilsonj/



Sat, 06 Jul 2002 03:00:00 GMT  
 I need help from a vb and vc++ expert
Also note that Visual Basic only supports Standard Calls, so don't forget to
add _stdcall to the C declaration of your function, i.e.:
int _stdcall MyFunction(...)
{...}

Regards,
Pieter Philippaerts
http://kpdweb.cjb.net/



Quote:
> I am having trouble getting vb to call my vc++ dll. Everytime I run my
> demo,
> I get a GPF. The visual c++ demo program I wrote works fine. If there is
> anyone
> out there who is an expert on matters concerning the use of and writing
> of vc++
> dlls for vb then e-mail me and I will send you the visual c++ dll and
> source
> and the vb demo program and source. BTW I am using visual studio 6 to do
> all this.

> --
> Jonathan Wilson

> http://members.xoom.com/wilsonj/



Sat, 06 Jul 2002 03:00:00 GMT  
 I need help from a vb and vc++ expert
Also, make sure you pass all strings "ByVal" (see MSDN article about passing
strings to DLLs)

Adam Kehler


Quote:
> Also note that Visual Basic only supports Standard Calls, so don't forget
to
> add _stdcall to the C declaration of your function, i.e.:
> int _stdcall MyFunction(...)
> {...}

> Regards,
> Pieter Philippaerts
> http://kpdweb.cjb.net/



> > I am having trouble getting vb to call my vc++ dll. Everytime I run my
> > demo,
> > I get a GPF. The visual c++ demo program I wrote works fine. If there is
> > anyone
> > out there who is an expert on matters concerning the use of and writing
> > of vc++
> > dlls for vb then e-mail me and I will send you the visual c++ dll and
> > source
> > and the vb demo program and source. BTW I am using visual studio 6 to do
> > all this.

> > --
> > Jonathan Wilson

> > http://members.xoom.com/wilsonj/



Sat, 06 Jul 2002 03:00:00 GMT  
 I need help from a vb and vc++ expert
I am having trouble getting vb to call my vc++ dll. Everytime I run my
demo,
I get a GPF. The visual c++ demo program I wrote works fine. If there is
anyone
out there who is an expert on matters concerning the use of and writing
of vc++
dlls for vb then e-mail me and I will send you the visual c++ dll and
source
and the vb demo program and source. BTW I am using visual studio 6 to do
all this.

--
Jonathan Wilson

http://members.xoom.com/wilsonj/



Sun, 07 Jul 2002 03:00:00 GMT  
 I need help from a vb and vc++ expert
Don't worry, I figured out the problem. I was allocating an array of 0 elements
because the VB constant I was pasing to redim was not declared public in the bas

module so therefore the program was gpfing when the dll tried to access memory
it wasn't allowed to access.

Quote:

> Also note that Visual Basic only supports Standard Calls, so don't forget to
> add _stdcall to the C declaration of your function, i.e.:
> int _stdcall MyFunction(...)
> {...}

> Regards,
> Pieter Philippaerts
> http://kpdweb.cjb.net/



> > I am having trouble getting vb to call my vc++ dll. Everytime I run my
> > demo,
> > I get a GPF. The visual c++ demo program I wrote works fine. If there is
> > anyone
> > out there who is an expert on matters concerning the use of and writing
> > of vc++
> > dlls for vb then e-mail me and I will send you the visual c++ dll and
> > source
> > and the vb demo program and source. BTW I am using visual studio 6 to do
> > all this.

> > --
> > Jonathan Wilson

> > http://members.xoom.com/wilsonj/

--
Jonathan Wilson

http://members.xoom.com/wilsonj/


Sun, 07 Jul 2002 03:00:00 GMT  
 I need help from a vb and vc++ expert
Don't worry, I figured out the problem. I was allocating an array of 0
elements
because the VB constant I was pasing to redim was not declared public in the
bas
module so therefore the program was gpfing when the dll tried to access memory

it wasn't allowed to access.

Quote:

> Jonathan,
>  When you are calling the VC++ DLL's from your program , check the
> declaration , the data types and ByRef / ByVal properties. You may need to
> change the data-types from VC DLL to VB , probably that's what is causing
> the problem.

> Regards,
> Adheer.



> > I am having trouble getting vb to call my vc++ dll. Everytime I run my
> > demo,
> > I get a GPF. The visual c++ demo program I wrote works fine. If there is
> > anyone
> > out there who is an expert on matters concerning the use of and writing
> > of vc++
> > dlls for vb then e-mail me and I will send you the visual c++ dll and
> > source
> > and the vb demo program and source. BTW I am using visual studio 6 to do
> > all this.

> > --
> > Jonathan Wilson

> > http://members.xoom.com/wilsonj/

--
Jonathan Wilson

http://members.xoom.com/wilsonj/


Sun, 07 Jul 2002 03:00:00 GMT  
 I need help from a vb and vc++ expert
Don't worry, I figured out the problem. I was allocating an array of 0 elements
because the VB constant I was pasing to redim was not declared public in the bas

module so therefore the program was gpfing when the dll tried to access memory
it wasn't allowed to access.

Quote:

> Also, make sure you pass all strings "ByVal" (see MSDN article about passing
> strings to DLLs)

> Adam Kehler



> > Also note that Visual Basic only supports Standard Calls, so don't forget
> to
> > add _stdcall to the C declaration of your function, i.e.:
> > int _stdcall MyFunction(...)
> > {...}

> > Regards,
> > Pieter Philippaerts
> > http://kpdweb.cjb.net/



> > > I am having trouble getting vb to call my vc++ dll. Everytime I run my
> > > demo,
> > > I get a GPF. The visual c++ demo program I wrote works fine. If there is
> > > anyone
> > > out there who is an expert on matters concerning the use of and writing
> > > of vc++
> > > dlls for vb then e-mail me and I will send you the visual c++ dll and
> > > source
> > > and the vb demo program and source. BTW I am using visual studio 6 to do
> > > all this.

> > > --
> > > Jonathan Wilson

> > > http://members.xoom.com/wilsonj/

--
Jonathan Wilson

http://members.xoom.com/wilsonj/


Sun, 07 Jul 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. I need help from a vb and vc++ expert

2. Need help passing a DC handle from vb to a vc++ dll

3. Need help passing a DC to a vc++ dll

4. Need help passing a DC to a vc++ dll

5. VB5 or VC++ ~~ Your Expert Advice is Needed!

6. HELP NEEDED: VB3.0 vs VC/C++ 1.52 DLL

7. I need vc ide macro help, trying to create a move to end of word macro

8. VC-COM from VB/VC/Script

9. Experts! VB Script help needed

10. VB Expert HELP needed: Tricky function naming problem

11. Expert Help In VB Needed

12. Need help from VB Data Environment Expert ?

 

 
Powered by phpBB® Forum Software