Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / December 2004

Tip: Looking for answers? Try searching our database.

Error calling API from VB.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Miller - 10 Dec 2004 20:59 GMT
I am attempting to call a function on the RightFax API from VB.NET.  The
original declaration for the function in VB 6.0 is:

Declare Function RFVB_SendFiles1 Lib "RF2VB.DLL" (ByVal hServer As Long, _
                                                 ByVal lFI10Object As Long, _
                                                 ByVal lNI10Object As Long, _
                                                 ByVal fSendWithCover As
Boolean, _
                                                 sCoverSheetModel As
String, _
                                                 aFiles() As String, _
                                                 hNewFax As Long) As Long

When translated to VB.NET the declaration looks like:

Declare Function RFVB_SendFiles1 Lib "RF2VB.DLL" (ByVal hServer As Integer, _
ByVal lFI10Object As Integer, _
ByVal lNI10Object As Integer, _
ByVal fSendWithCover As Boolean, _
ByRef sCoverSheetModel As String, _
ByRef aFiles() As String, _
ByRef hNewFax As Integer) As Integer

I call the function with the line:

lError = RFVB_SendFiles1(hServer, lFI10Obj, lNI10Obj, 1, "", aFiles, lHandle)

where:

·    hServer is an integer
·    lFI10Obj is an integer
·    lNI10Obj is an integer
·    aFiles is a string array of 8 elements with only the first element set to
a value.
·    lHandle is an integer

Whenever I hit the call I get an error message back from the DLL about an
invalid parameter.  Could I be violating a word boundary or not initializing
the string array correctly?  I’m stumped.

Steve Miller
AllTech Inc.
swmiller@rocketmail.com
Eric Carlson - 10 Dec 2004 21:55 GMT
Did you try passing your string array byval instead of byref ?
Steve Miller - 10 Dec 2004 22:45 GMT
Yes, I got the same error message.

> Did you try passing your string array byval instead of byref ?
Eric Carlson - 12 Dec 2004 06:17 GMT
Okay, i think you are correct when you pass the string array as value (from
what i have read)

Your problem might be with the boolean.. i think that booleans are
represented differently from vb6 to vb.net.  You might try using the marshal
boolean attribute on that paremter... or setting up the parameter as the
correct size data type (i.e. "short" or whatever is the correct data size for
vb6 boolean).

Just some ideas....

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.