473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Declare Sub XXX Lib "X.dll" (Structure vs Class) ...

Hello -

I have an Ada *.dll that is called from withing VB.NET. The following
works ...

Public Declare Sub XXX Lib "X.dll" (ByRef XArgument As XStructure)

<StructLayout(LayoutKind.Explicit)_
Structure XStructure
<FieldOffset(0)Dim A As Single
<FieldOffset(4)Dim B As Single
...
End Structure

.... but I would like to use a Class to utilize inheritance. Here is
what does not work ...

Public Declare Sub XXX Lib "X.dll" (ByRef XArgument As XClassBase)

Class XClassBase
End Class

<StructLayout(LayoutKind.Explicit)_
Class XClassDerived
Inherits XClassBase

<FieldOffset(0)Dim A As Single
<FieldOffset(4)Dim B As Single
...
End Class

.... when I call it using ...

Dim lDummy as New XClassDerived
XXX(CType(lDummy, XClassDerived))

I assume that the Class stores some additional data that confuses the
interface to teh X.dll? Is there any way to make this work???

Thanks!
Joe

Oct 30 '07 #1
8 3933
"Joe HM" <un*******@yahoo.comschrieb
Dim lDummy as New XClassDerived
XXX(CType(lDummy, XClassDerived))

I assume that the Class stores some additional data that confuses
the interface to teh X.dll?
No. A structure is a value type. A class is a reference type. Using ByRef,
the reference to the passed value is passed. Using ByVal.... wait...

http://groups.google.com/group/micro...e83beb9988aabf

Is there any way to make this work???
Change it to ByVal: (ByVal XArgument As XClassBase)
Armin

Oct 30 '07 #2
Hello -

Thanks for the information! Using ByVal will not make it abort
anymore but the function in the X.dll that is called modifies the
fields of the data passed in. So I need to use ByRef to get to the
modified values.

Is there any way to make this work with ByRef?

Thanks,
Joe

On Oct 30, 8:54 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"Joe HM" <unixve...@yahoo.comschrieb
Dim lDummy as New XClassDerived
XXX(CType(lDummy, XClassDerived))
I assume that the Class stores some additional data that confuses
the interface to teh X.dll?

No. A structure is a value type. A class is a reference type. Using ByRef,
the reference to the passed value is passed. Using ByVal.... wait...

http://groups.google.com/group/micro...languages.vb/m...
Is there any way to make this work???

Change it to ByVal: (ByVal XArgument As XClassBase)

Armin
Oct 30 '07 #3
Passing a reference type byval does allow the function to change the passed
type. ByVal of a reference type, passes the reference, allowing the routine
to change the object that the reference points to. ByRef of a reference
type, passes a reference to the reference, allowing the routine to change the
reference!
--
Terry
"Joe HM" wrote:
Hello -

Thanks for the information! Using ByVal will not make it abort
anymore but the function in the X.dll that is called modifies the
fields of the data passed in. So I need to use ByRef to get to the
modified values.

Is there any way to make this work with ByRef?

Thanks,
Joe

On Oct 30, 8:54 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"Joe HM" <unixve...@yahoo.comschrieb
Dim lDummy as New XClassDerived
XXX(CType(lDummy, XClassDerived))
I assume that the Class stores some additional data that confuses
the interface to teh X.dll?
No. A structure is a value type. A class is a reference type. Using ByRef,
the reference to the passed value is passed. Using ByVal.... wait...

http://groups.google.com/group/micro...languages.vb/m...
Is there any way to make this work???
Change it to ByVal: (ByVal XArgument As XClassBase)

Armin

Oct 30 '07 #4
Yep ... that was my point. I need this to work with ByRef ... any
ideas?

Thanks!
Joe

On Oct 30, 9:48 am, Terry <Ter...@nospam.nospamwrote:
Passing a reference type byval does allow the function to change the passed
type. ByVal of a reference type, passes the reference, allowing the routine
to change the object that the reference points to. ByRef of a reference
type, passes a reference to the reference, allowing the routine to change the
reference!
--
Terry

"Joe HM" wrote:
Hello -
Thanks for the information! Using ByVal will not make it abort
anymore but the function in the X.dll that is called modifies the
fields of the data passed in. So I need to use ByRef to get to the
modified values.
Is there any way to make this work with ByRef?
Thanks,
Joe
On Oct 30, 8:54 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"Joe HM" <unixve...@yahoo.comschrieb
Dim lDummy as New XClassDerived
XXX(CType(lDummy, XClassDerived))
I assume that the Class stores some additional data that confuses
the interface to teh X.dll?
No. A structure is a value type. A class is a reference type. Using ByRef,
the reference to the passed value is passed. Using ByVal.... wait...
>http://groups.google.com/group/micro...languages.vb/m...
Is there any way to make this work???
Change it to ByVal: (ByVal XArgument As XClassBase)
Armin- Hide quoted text -

- Show quoted text -
Oct 30 '07 #5
Yep ... that was my point. I need this to work with ByRef ... any
ideas?

I *think* Terry was trying to say that you can change your declaration to
ByVal and you will still be able to change the fields of the param in question.
ByVal only prevents you from assigning a new object to the param.

--
Rory
Oct 30 '07 #6
you had said ..."but the function in the X.dll that is called modifies the
fields of the data passed in"
And I am saying, passing a reference type byval DOES allow that. When
passing a reference type byval, a copy of the REFERENCE (not the object the
reference points to) is passed to the function so that there are now 2
references to the SAME object.
Now having said all that, I am not familiar with Ada, so I don't know if
that presents any additional complications.
--
Terry
"Joe HM" wrote:
Yep ... that was my point. I need this to work with ByRef ... any
ideas?

Thanks!
Joe

On Oct 30, 9:48 am, Terry <Ter...@nospam.nospamwrote:
Passing a reference type byval does allow the function to change the passed
type. ByVal of a reference type, passes the reference, allowing the routine
to change the object that the reference points to. ByRef of a reference
type, passes a reference to the reference, allowing the routine to change the
reference!
--
Terry

"Joe HM" wrote:
Hello -
Thanks for the information! Using ByVal will not make it abort
anymore but the function in the X.dll that is called modifies the
fields of the data passed in. So I need to use ByRef to get to the
modified values.
Is there any way to make this work with ByRef?
Thanks,
Joe
On Oct 30, 8:54 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"Joe HM" <unixve...@yahoo.comschrieb
Dim lDummy as New XClassDerived
XXX(CType(lDummy, XClassDerived))
I assume that the Class stores some additional data that confuses
the interface to teh X.dll?
No. A structure is a value type. A class is a reference type. Using ByRef,
the reference to the passed value is passed. Using ByVal.... wait...
http://groups.google.com/group/micro...languages.vb/m...
Is there any way to make this work???
Change it to ByVal: (ByVal XArgument As XClassBase)
Armin- Hide quoted text -
- Show quoted text -

Oct 30 '07 #7
Hello -

Sorry guys ... I guess I did not pay attention when I read this. I
remember the concept of passing in a copy of the reference from C++.
I did not create the *.dll but I can talk to the person who did to see
whether this can be done in Ada.

Thanks!
Joe

On Oct 30, 10:51 am, Terry <Ter...@nospam.nospamwrote:
you had said ..."but the function in the X.dll that is called modifies the
fields of the data passed in"
And I am saying, passing a reference type byval DOES allow that. When
passing a reference type byval, a copy of the REFERENCE (not the object the
reference points to) is passed to the function so that there are now 2
references to the SAME object.
Now having said all that, I am not familiar with Ada, so I don't know if
that presents any additional complications.
--
Terry

"Joe HM" wrote:
Yep ... that was my point. I need this to work with ByRef ... any
ideas?
Thanks!
Joe
On Oct 30, 9:48 am, Terry <Ter...@nospam.nospamwrote:
Passing a reference type byval does allow the function to change the passed
type. ByVal of a reference type, passes the reference, allowing the routine
to change the object that the reference points to. ByRef of a reference
type, passes a reference to the reference, allowing the routine to change the
reference!
--
Terry
"Joe HM" wrote:
Hello -
Thanks for the information! Using ByVal will not make it abort
anymore but the function in the X.dll that is called modifies the
fields of the data passed in. So I need to use ByRef to get to the
modified values.
Is there any way to make this work with ByRef?
Thanks,
Joe
On Oct 30, 8:54 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"Joe HM" <unixve...@yahoo.comschrieb
Dim lDummy as New XClassDerived
XXX(CType(lDummy, XClassDerived))
I assume that the Class stores some additional data that confuses
the interface to teh X.dll?
No. A structure is a value type. A class is a reference type. Using ByRef,
the reference to the passed value is passed. Using ByVal.... wait...
>http://groups.google.com/group/micro...languages.vb/m...
Is there any way to make this work???
Change it to ByVal: (ByVal XArgument As XClassBase)
Armin- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Oct 30 '07 #8
No you don't need ByRef. In either case the called routine can modify
the contents of the class or structure.

With ByRef the called routine can allocate a new instance of the class
and change the reference in the caller. With ByVal the caller's
reference can't change.

On Tue, 30 Oct 2007 06:18:00 -0700, Joe HM <un*******@yahoo.com>
wrote:
>Hello -

Thanks for the information! Using ByVal will not make it abort
anymore but the function in the X.dll that is called modifies the
fields of the data passed in. So I need to use ByRef to get to the
modified values.

Is there any way to make this work with ByRef?

Thanks,
Joe

On Oct 30, 8:54 am, "Armin Zingler" <az.nos...@freenet.dewrote:
>"Joe HM" <unixve...@yahoo.comschrieb
Dim lDummy as New XClassDerived
XXX(CType(lDummy, XClassDerived))
I assume that the Class stores some additional data that confuses
the interface to teh X.dll?

No. A structure is a value type. A class is a reference type. Using ByRef,
the reference to the passed value is passed. Using ByVal.... wait...

http://groups.google.com/group/micro...languages.vb/m...
Is there any way to make this work???

Change it to ByVal: (ByVal XArgument As XClassBase)

Armin
Oct 30 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jr | last post by:
I am working in VC++ so this may be microsoft specific though I don't think so. Excuse me if it is. Assuming it isn't, can someone generally explain the purpose of having both - is it purely a...
1
by: Ya Ya | last post by:
I am developing a DLL (class library) for a web application of mine. In the web.config of the web application I have set: culture="en-GB" uiCulture="en" in order that the date format will be...
0
by: Rodolfo | last post by:
Hi all.... I have to develop a class application but I must use a COM+ DLL (vb6) intalled in a remote COM+ server. The proxy application is already installed in IIS server but I can't use any...
0
by: Qwert | last post by:
Hello, kind of a specific question, but here it goes: The following code works: Dim objGraphicsSource As Graphics = PictureBox1.CreateGraphics Dim bmpSource As New Bitmap(PictureBox1.Width,...
0
by: gbaitsur | last post by:
Hi! I really hope that someone could help me. I have a vb.net application that uses the unmanaged dll, which is part of an independent software. The code is: Declare Sub SUB_NAME Lib...
4
by: Michael Rodriguez | last post by:
I have a data layer in a dll class. If I manually throw an exception in that data layer, the generic Application.OnThreadException in my UI does not catch it nor does it display any message...
5
by: sharat | last post by:
hi all can any body tell how to declare the structure pointer within a class. i have written the following program but gettin error. #include<iostream> using namespace std;
13
by: Javad | last post by:
Hello I know that I should get the information of windows internet connections by using "rasapi32.dll" library, and I also have some sample codes, but I can't make them work. My exact need is to...
0
by: Joe HM | last post by:
Hello - I have a *.dll that was compiled from Ada. The following declaration and Structure is working ... Declare Sub XXX Lib "X.dll" (ByRef XState As XStructure) ...
2
by: Ronny | last post by:
I have a standard C# windows application with one form and some logic around it. I need to onvert this exe into a dll class library and use it's functionality from another exe. Is there in easy...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.