Discussion:
Creating DLLs
(too old to reply)
EvilDonut
2003-09-24 23:45:10 UTC
Permalink
How do I create a DLL which other languages like VB can use? I managed to
create a DLL but it cant be used by anything other than pascal.

My code looks like:
-----
Library Fan;
<some stuff>

Procedure SendPortData (toSend:byte); export;

<some more stuff>

exports SendPortData;

BEGIN
END.
-----

This compiles fine into a dll, but regsvr32.exe won't recognise it, nor will
VB. Basically I want to call SendPortData from VB, how would I go about
this?
Jose Perez
2003-09-25 16:37:25 UTC
Permalink
Post by EvilDonut
How do I create a DLL which other languages like VB can use? I managed to
create a DLL but it cant be used by anything other than pascal.
-----
Library Fan;
<some stuff>
Procedure SendPortData (toSend:byte); export;
<some more stuff>
exports SendPortData;
BEGIN
END.
-----
This compiles fine into a dll, but regsvr32.exe won't recognise it, nor will
VB. Basically I want to call SendPortData from VB, how would I go about
this?
Your problem might be that you are creating 16-bit DLLs. Unless you are
using an older version of VB, your VB app will have to use thunking
(something which I have never tried) to access the DLL. Try using a 32-bit
Pascal compiler like Gnu Pascal or Delphi 2, 3, ..., 7.
EvilDonut
2003-09-25 22:41:33 UTC
Permalink
Thanks, I think you are right about it making a 16-bit DLL. I have tried
lots of compilers, but hardly any seem to recognise this code:
addr:=MemW[$0040:$0008];
Port[addr]:=1;
Basically it writes raw data to my parallel port, which is something that I
can't seem to accomplish in any other language because NT-type systems dont
like you accessing ports from anything other than kernel-mode drivers. But
for some reason the above code doesnt need those permissions. Thats why I'm
using pascal to write a DLL - so I can use the above code in my VB/VC++
apps. Another solution to the above problem would be to convert the above 2
lines into C code. Do you know how to do this? If I knew the C equivalent of
that code that would completely solve the problem, but unfortunately I can't
find any examples on the net where people write to ports in this way, so it
would be a great help if anyone here knew :)

If not I guess I'll have to look into that thunking thing because I can't
compile the above code on any compiler apart from turbo pascal, thanks to
its arrays mapped to DOS memory.
Post by Jose Perez
Post by EvilDonut
How do I create a DLL which other languages like VB can use? I managed to
create a DLL but it cant be used by anything other than pascal.
-----
Library Fan;
<some stuff>
Procedure SendPortData (toSend:byte); export;
<some more stuff>
exports SendPortData;
BEGIN
END.
-----
This compiles fine into a dll, but regsvr32.exe won't recognise it, nor
will
Post by EvilDonut
VB. Basically I want to call SendPortData from VB, how would I go about
this?
Your problem might be that you are creating 16-bit DLLs. Unless you are
using an older version of VB, your VB app will have to use thunking
(something which I have never tried) to access the DLL. Try using a 32-bit
Pascal compiler like Gnu Pascal or Delphi 2, 3, ..., 7.
Loading...