|
-
Jan 17th, 2002, 10:08 AM
#1
Thread Starter
Member
UDT passed to a DLL
Hi folks, I must be stupid or something. I can't get the following
very simple code to work. Any help would be greatly appreciated as I can't find the answer. Regards, Mark ([email protected])
P.S The stuff below this line pastes straight into a .BAS file.
==============================================
'I expect the following output from Sub CreateRecords...
' 1
' 2
'A Variable Length String
' 3
' 4
' 5
'Another Variable Length String
' 6
Type RECORD
A As Double
B As Long
C As String
D As Long
End Type
Global Recs(1 To 2) As RECORD
Declare Sub DLLDillon Lib "\Chappel.23\Source\C\Useful23\Debug\useful23.dll" (TwoRecords As RECORD)
Sub CreateRecords()
Recs(1).C = "A Variable Length String"
Recs(2).C = "Another Variable Length String"
Call DLLDillon(Recs(1))
Debug.Print Recs(1).A
Debug.Print Recs(1).B
Debug.Print Recs(1).C
Debug.Print Recs(1).D
Debug.Print Recs(2).A
Debug.Print Recs(2).B
Debug.Print Recs(2).C
Debug.Print Recs(2).D
End Sub
'My attempt at the 'C' end follows...
'struct RECORD
'{
' double a;
' long b;
' long c;
' long d;
'};
'VOID FAR PASCAL DLLDillon(struct RECORD FAR* Recs)
'{
' Recs[0].a = 1;
' Recs[0].b = 2;
' //Recs[0].c = Don't even touch field 'c'
' Recs[0].d = 3;
' Recs[1].a = 4;
' Recs[1].b = 5;
' //Recs[0].c = Don't even touch field 'c'
' Recs[1].d = 6;
'}
-
Jan 17th, 2002, 10:29 AM
#2
What's the problem?
Try to use (ByVal pRecords as Long) as parameters in the declare statement. Then pass VarPtr(Recs(1)) as argument. On the C side nothing changes.
C side: FAR and PASCAL are not used anymore. In VC++, PASCAL is replaced by __stdcall, other compilers will have similar things. FAR is not needed in 32-bit environments.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 17th, 2002, 02:19 PM
#3
Monday Morning Lunatic
__stdcall == WINAPI, and is the more general across compilers.
What I don't get is MS's love of having lots of names for EXACTLY THE SAME SODDING TYPE! 
*rant over*
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 17th, 2002, 03:04 PM
#4
transcendental analytic
Originally posted by parksie
__stdcall == WINAPI, and is the more general across compilers.
What I don't get is MS's love of having lots of names for EXACTLY THE SAME SODDING TYPE! 
*rant over*
Layering parksie layering what if microsoft wanted to change a datatype? Then they'd have to take the complaints of all programmers that would need to change it in every single little app.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 18th, 2002, 04:27 AM
#5
Monday Morning Lunatic
Still doesn't explain why there's STDCALL, WINAPI, CALLBACK, PASCAL, and most likely others as well for what is essentially __stdcall.
(However, they still do stupid things like typedef float FLOAT )
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 18th, 2002, 06:53 AM
#6
transcendental analytic
same datatype for different purposes, you'll learn to know what it means in BORK
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 21st, 2002, 06:09 PM
#7
WINAPI and CALLBACK were different things in Win16...
And imagine a win32 compiler that doesn't know __stdcall (a gcc port maybe). This could be helped by simply adding one line in the sdk headers
#ifdef THIS_IS_MY_OWN_COMPILER
#define WINAPI _my_weird_stdcall_name
#endif
And everything will be compiled as it should...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|